MySQL Utility Users' Console Oerview

Posted by rudrap on Oracle Blogs See other posts from Oracle Blogs or by rudrap
Published on Mon, 5 Nov 2012 05:01:08 +0000 Indexed on 2012/11/05 11:17 UTC
Read the original article Hit count: 210

Filed under:

MySQL Utility Users' Console (mysqluc):

The MySQL Utilities Users' Console is designed to make using the utilities easier via a dedicated console. It helps us to use the utilities without worrying about the python and utility paths.


Why do we need a special console?

- It does provide a unique shell environment with command completion, help for each utility, user defined variables, and type completion for options.

- You no longer have to type out the entire name of the utility.

- You don't need to remember the name of a database utility you want to use.

- You can define variables and reuse them in your utility commands.

- It is possible to run utility command along with mysqluc and come out of the mysqluc console.


Console commands:

mysqluc> help

Command Description

----------------------           ---------------------------------------------------

help utilities                     Display list of all utilities supported.

help <utility>                  Display help for a specific utility.

help or help commands   Show this list.

exit or quit                       Exit the console.

set <variable>=<value>  Store a variable for recall in commands.

show options                   Display list of options specified by the user on launch.

show variables                 Display list of variables.

<ENTER>                       Press ENTER to execute command.

<ESCAPE>                     Press ESCAPE to clear the command entry.

<DOWN>                       Press DOWN to retrieve the previous command.

<UP>                               Press UP to retrieve the next command in history.

<TAB>                            Press TAB for type completion of utility, option,or variable names.

<TAB><TAB>                Press TAB twice for list of matching type completion (context sensitive).


How do I use it?

Pre-requisites:

- Download the latest version of MySQL Workbench.

- Mysql Servers are running.

- Your Pythonpath is set. (e.g. Export PYTHONPATH=/...../mysql-utilities/)


Check the Version of mysqluc Utility:

/usr/bin/python mysqluc.py –version

It should display something like this

MySQL Utilities mysqluc.py version 1.1.0 - MySQL Workbench Distribution 5.2.44

Copyright (c) 2010, 2012 Oracle and/or its affiliates. All rights reserved.

This program is free software; see the source for copying

conditions. There is NO warranty; not even for MERCHANTABILITY or

FITNESS FOR A PARTICULAR PURPOSE, to the extent permitted by law.


Use of TAB to get the current utilities:

mysqluc> mysqldb<TAB><TAB>

Utility Description

-------------        ------------------------------------------------------------

mysqldbcopy      copy databases from one server to another

mysqldbexport    export metadata and data from databases

mysqldbimport    import metadata and data from files


mysqluc> mysqldbcopy –source=$se<TAB>

Variable  Value                                                                 
--------  ----------------------------------------------------------------------

server1 root@localhost:3306

server2 root@localhost:3307

you can see the variables starting with se and then decide which to use


Run a utility via the console:

/usr/bin/python mysqluc.py -e "mysqldbcopy --source=root@localhost:3306 --destination=root@localhost:3307 dbname"

Get help for utilities in the console:

mysqluc> help utilities

Display help for a utility

mysqluc> help mysqldbcopy

Details about mysqldbcopy and its options

set variables and use them in commands:

mysqluc> set server1 = root@localhost:3306

mysqluc>show variables

Variable  Value                                                                 
--------    ----------------------------------------------------------------------

server1    root@localhost:3306

server2    root@localhost:3307

mysqluc> mysqldbcopy –source=$server1 –destination=$server2 dbname <Enter>

Mysqldbcopy utility output will display.

mysqluc>show options

Display list of options specified by the user

mysqluc SERVER=root@host123 VAR_A=57 -e "show variables"

  Variable  Value                                                            
  --------    -----------------------------------------------------------------
  SERVER    root@host123                                                     
  VAR_A      57
Finding option names for an Utility:
mysqluc> mysqlserverclone --n
Option               Description                                              
-------------------  ---------------------------------------------------------
--new-data=NEW_DATA  the full path to the location of the data directory for  
                     the new instance                                         
--new-port=NEW_PORT  the new port for the new instance - default=3307         
--new-id=NEW_ID      the server_id for the new instance - default=2

Limitations:

User defined variables have a lifetime of the console run time.

© Oracle Blogs or respective owner

Related posts about /Oracle