Documentation Home
MySQL Utilities 1.6 Manual
Related Documentation Download this Manual
PDF (US Ltr) - 1.2Mb
PDF (A4) - 1.2Mb
EPUB - 288.4Kb
HTML Download (TGZ) - 209.1Kb
HTML Download (Zip) - 221.8Kb


MySQL Utilities 1.6 Manual  /  ...  /  Is there an easy way to know what options are used with each utility?

Beta Draft: 2016-09-26

3.3.4 Is there an easy way to know what options are used with each utility?

There are many utilities and it is not always easy to remember all of the options and parameters associated with each. Sometimes we need to run several utilities using nearly the same options. For example, you may want to run several utilities logging into a particular server. Rather than retype the connection information each time, you would like to save the option value some way and reuse it.

Fortunately, the mysqluc utility does this and more. It is named the MySQL Users' Console and provides type completion for options, utility names, and even user-defined variables for working with common option values. Not only that, it also provides the ability to get help for any utility supported.

Objectives

Discover what utilities exist and find the options for certain utilities.

Run several utilities with the same server using the type completion feature to make using the suite of utilities easier.

Example Execution

Note

In the example below, keystrokes are represented using square brackets. For example, [TAB] indicates the tab key was pressed. Similarly, portions in the commands specific with angle brackets are values you would replace with actual values. For example, <user> indicates you would place the user's login name here.


shell> mysqluc
Launching console ...

Welcome to the MySQL Utilities Client (mysqluc) version 1.6.4
Copyright (c) 2010, 2016 Oracle and/or its affiliates. All rights reserved.
This is a release of dual licensed MySQL Utilities. For the avoidance of
doubt, this particular copy of the software is released
under the version 2 of the GNU General Public License.
MySQL Utilities is brought to you by Oracle.

Type 'help' for a list of commands or press TAB twice for list of utilities.

mysqluc> help
Command                 Description                                      
----------------------  ---------------------------------------------------
help utilities          Display list of all utilities supported.         
help <utility>          Display help for a specific utility.             
show errors             Display errors captured during the execution of the
                        utilities.                                       
clear errors            clear captured errors.                           
show last error         Display the last error captured during the       
                        execution of the utilities                       
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 
                        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).

mysqluc> help utilities
Utility           Description                                            
----------------  ---------------------------------------------------------
mysqlauditadmin    audit log maintenance utility                         
mysqlauditgrep     audit log search utility                              
mysqlbinlogmove    binary log relocate utility                           
mysqlbinlogpurge   purges unnecessary binary log files                   
mysqlbinlogrotate  rotates the active binary log file                    
mysqldbcompare     compare databases for consistency                     
mysqldbcopy        copy databases from one server to another             
mysqldbexport      export metadata and data from databases               
mysqldbimport      import metadata and data from files                   
mysqldiff          compare object definitions among objects where the    
                   difference is how db1.obj1 differs from db2.obj2      
mysqldiskusage     show disk usage for databases                         
mysqlfailover      automatic replication health monitoring and failover  
mysqlfrm           show CREATE TABLE from .frm files                     
mysqlgrants        display grants per object                             
mysqlindexcheck    check for duplicate or redundant indexes              
mysqlmetagrep      search metadata                                       
mysqlprocgrep      search process information                            
mysqlreplicate     establish replication with a master                   
mysqlrpladmin      administration utility for MySQL replication          
mysqlrplcheck      check replication                                     
mysqlrplms         establish multi-source replication                    
mysqlrplshow       show slaves attached to a master                      
mysqlrplsync       replication synchronization checker utility           
mysqlserverclone   start another instance of a running server            
mysqlserverinfo    show server information                               
mysqlslavetrx      skip transactions on slaves                           
mysqluserclone     clone a MySQL user account to one or more new users   

mysqluc> help mysqldb[TAB][TAB]
Utility         Description                                              
--------------  -----------------------------------------------------------
mysqldbcompare  compare databases for consistency                        
mysqldbcopy     copy databases from one server to another                
mysqldbexport   export metadata and data from databases                  
mysqldbimport   import metadata and data from files


mysqluc> mysqlrplshow --m[TAB][TAB]

Option                 Description                                       
---------------------  ----------------------------------------------------
--master=MASTER        connection information for master server in the   
                       form: <user>[:<password>]@<host>[:<port>][:<socket>]
                       or <login-path>[:<port>][:<socket>].              
--max-depth=MAX_DEPTH  limit the traversal to this depth. Valid only with
                       the --recurse option. Valid values are non-negative
                       integers.        

mysqluc> mysqlrplshow --mast[TAB]er=<user>:<password>@localhost:13001

The console has detected that the utility 'mysqlrplshow' ended with an error code.
You can get more information about the error by running the console command 'show last error'.

mysqluc> show last error
Execution of utility: mysqlrplshow --master=<user>:<password>@localhost:13001
returned errorcode: 2 with error message:
Usage: mysqlrplshow.py --master=root@localhost:3306

mysqlrplshow.py: error: The --discover-slaves-login is required to test slave connectivity.

mysqluc> mysqlrplshow --master=<user>:<password>@localhost:13001 \
            --discover-slaves-login=<user>:<password>
# master on localhost: ... connected.
# Finding slaves for master: localhost:13001

# Replication Topology Graph
localhost:13001 (MASTER)
   |
   +--- localhost:13002 - (SLAVE)
   |
   +--- localhost:13003 - (SLAVE)
   |
   +--- localhost:13004 - (SLAVE)
   |
   +--- localhost:13005 - (SLAVE)


mysqluc>   

Discussion

There is a lot going on here in this example! Let's look through the command entries as they occur in the text.

The first command, mysqluc, starts the users' console. Once the console starts, you will see a welcome banner followed by a simple prompt, mysqluc>. No additional options or parameters are necessary. However, it should be noted that you can pass commands to the console to execute on start. For a complete list of options, see MySQL Users' Console manual page.

The next command, help, shows the help for the users' console itself. As you can see, there are a number of options available. You can set user defined variables, discover the help for other utilities, display the latest error, and see the options used to start the console.

The help utilities command shows you a list of the available utilities and a short description of each.

Next, we decide we want to get help for one of the database utilities but we do not remember the name. We know it starts with mysqldb but we are not sure of the rest. In this case, if we type mysqldb then hit TAB twice, the users' console will show us a list of all of the utilities that begin with mysqldb.

Now let's say we want to see a graph of our replication topology but we are not sure what the option for specifying the master. In this case, we type the command to launch the mysqlrplshow utility and type the start of the option, '--m', then press TAB twice. What we see is there are two options that match that prefix. Notice we also see a short description (help) for each. This is a real time saving feature for the users' console.

Notice in the next segment we do not have to type the entire name of the option. In this case we typed '--mast[TAB]' which the users' console completed with '--master='. This is tab completion for option names.

Notice the result of the command we entered, mysqlrplshow '--master=<user>:<password>@localhost:13001'. There was an error here. We can see the error with the show errors command. We see in the error we failed to provide any connection information for the slaves.

Once we correct that omission, the last command shows how the users' console executes a utility and displays the results in the same stream as the console - much like the mysql client command-line tool.

Permissions Required

There are no special permissions required to run mysqluc however, you must have the necessary privileges to execute the desired utilities.


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