Documentation Home
MySQL Utilities 1.6 Manual
Related Documentation Download this Manual
PDF (US Ltr) - 1.2Mb
PDF (A4) - 1.2Mb
EPUB - 288.8Kb
HTML Download (TGZ) - 209.9Kb
HTML Download (Zip) - 222.3Kb

MySQL Utilities 1.6 Manual  /  Manual Pages  /  mysqluc — Command line client for running MySQL Utilities

5.27 mysqluc — Command line client for running MySQL Utilities

This utility provides a command line environment for running MySQL Utilities.

The mysqluc utility, hence console, allows users to execute any of the currently installed MySQL Utilities commands (the MySQL Utility scripts such as mysqluserclone). The option --utildir is used to provide a path to the MySQL Utilities scripts if the location is different from where the utility is executed.

The console has a list of console or base commands. These allow the user to interact with the features of the console itself. The list of base commands is shown below along with a brief description.

Command                 Description
----------------------  ---------------------------------------------------
help utilities          Display list of all utilities supported.
help <utility>          Display help for a specific utility.
help | help commands    Show this list.
exit | 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
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).

One of the most helpful base commands is the ability to see the options for a given utility by typing 'help utility'. When the user enters this command, the console displays a list of all of the options for the utility.

The console provides tab completion for all commands, options for utilities, and user-defined variables. Tab completion for commands allows users to specify the starting N characters of a command and press TAB to complete the command. If there are more than one command that matches the prefix, and the user presses TAB twice, a list of all possible matches is displayed.

Tab completion for options is similar. The user must first type a valid MySQL Utility command then types the first N characters of a command and presses TAB, for example –-verbTAB. In this case, the console completes the option. For the cases where an option requires a value, the console completes the option name and append the '=' character. Tab completion for options works for both the full name and the alias (if available). If the user presses TAB twice, the console displays a list of matching options. Pressing TAB twice immediately after typing the name of a MySQL Utility displays a list of all options for that utility.

Tab completion for variables works the same as that for options. In this case, the user must first type the '$' character then press TAB. For example, if a variable $SERVER1 exists, when the user types –-server=$SERTAB, the console completes the $SERVER variable name. For cases where there are multiple variables, pressing TAB twice displays a list of all matches to the first $+N characters. Pressing TAB twice after typing only the $ character displays a list of all variables.


The 'mysql' prefix is optional in the console. For example, typing 'diskuTAB' in the console completes the command as 'diskusage '.

Executing utilities is accomplished by typing the complete command and pressing ENTER. The user does not have to type 'python' or provide the '.py' file extension. The console adds these if needed when the command is executed.

The user can also run commands using the option --execute. The value for this option is a semi-colon separated list of commands to execute. These can be base commands or MySQL Utility commands. The console executes each command and display the output. All commands to be run by the console must appear inside a quoted string and separated by semi-colons. Commands outside of the quoted string are treated as arguments for the mysqluc utility itself and thus ignored for execution.


In the console, an error in the console or related code stop sexecuting commands at the point of failure. Commands may also be piped into the console using a mechanism such as 'echo "commands" | mysqluc'.

The console also allows users to set user-defined variables for commonly used values in options. The syntax is simply 'set VARNAME=VALUE'. The user can see a list of all variables by entering the 'show variables' command. To use the values of these variables in utility commands, the user must prefix the value with a '$'. For example, --server=$SERVER1 substitutes the value of the SERVER1 user-defined variable when the utility is executed.


User-defined variables have a session lifetime. They are not saved from one execution to another in the users console.

User-defined variables may also be set by passing them as arguments to the mysqluc command. For example, to set the SERVER1 variable and launch the console, the user can launch the console using this command.:

shell> mysqluc SERVER1=root@localhost

The user can provide any number of user-defined variables but they must contain a value and no spaces around the '=' character. Once the console is launched, the user can see all variables using the 'show variables' command.


  • --version

    show program's version number and exit

  • --help

    show the program's help page

  • --license

    Display license information and exit.

  • --verbose, -v

    control how much information is displayed. For example, -v = verbose, -vv = more verbose, -vvv = debug

  • --quiet

    suppress all informational messages

  • --execute commands, -e commands

    Execute commands and exit. Multiple commands are separated with semi-colons.


    Some platforms may require double quotes around the command list.

  • --utildir path

    location of utilities

  • --width number

    Display width


Using the --execute option or piping commands to the console may require quotes or double quotes (for example, on Windows).


To launch the console, use this command:

shell> mysqluc

The following demonstrates launching the console and running the console command 'help utilities' to see a list of all utilities supported. The console executes the command then exits.:

shell> mysqluc -e "help utilities"

Utility           Description
----------------  ---------------------------------------------------------
mysqlindexcheck   check for duplicate or redundant indexes
mysqlrplcheck     check replication
mysqluserclone    clone a MySQL user account to one or more new users
mysqldbcompare    compare databases for consistency
mysqldiff         compare object definitions among objects where the
                  difference is how db1.obj1 differs from db2.obj2
mysqldbcopy       copy databases from one server to another
mysqlreplicate    establish replication with a master
mysqldbexport     export metadata and data from databases
mysqldbimport     import metadata and data from files
mysqlmetagrep     search metadata
mysqlprocgrep     search process information
mysqldiskusage    show disk usage for databases
mysqlserverinfo   show server information
mysqlserverclone  start another instance of a running server

The following demonstrates launching the console to run several commands using the --execute option to including setting a variable for a server connection and executing a utility using variable substitution.


It may be necessary to escape the '$' on some platforms, such as Linux.

The output below is an excerpt and is representational only:

shell> mysqluc -e "set SERVER=root@host123; mysqldiskusage --server=\$SERVER"

# Source on host123: ... connected.

NOTICE: Your user account does not have read access to the datadir. Data
sizes will be calculated and actual file sizes may be omitted. Some features
may be unavailable.

# Database totals:
| db_name            |       total  |
| world              |           0  |

Total database disk usage = 1,072,359,052 bytes or 1022.00 MB


The following demonstrates launching the console using the commands shown above but piped into the console on the command line. The results are the same as above.:

shell> echo "set SERVER=root@host123; mysqldiskusage --server=\$SERVER" | mysqluc

The following demonstrates launching the console and setting variables via the command line.:

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

Variable  Value
--------  -----------------------------------------------------------------
SERVER    root@host123
VAR_A     57


There are no special permissions required to run mysqluc however, you must have the necessary privileges to execute the desired utilities. See the PERMISSIONS REQUIRED section for each command you wish to execute.

User Comments
Sign Up Login You must be logged in to post a comment.