Commands
Introduction
Mycli sends most input you enter to the MySQL server as a SQL statement. There
is also a set of commands that mycli will accept. To see these, type help or
\? at the prompt:
mycli>help
+-------------+----------------------------+------------------------------------------------------------+
|Command|Shortcut|Description|
+-------------+----------------------------+------------------------------------------------------------+
|\G|\G|Displaycurrentqueryresultsvertically.|
|\dt|\dt[+][table]|Listordescribetables.|
|\e|\e|Editcommandwitheditor(uses$EDITOR).|
|\f|\f[name [args..]]|Listorexecutefavoritequeries.|
|\fd|\fd[name]|Deleteafavoritequery.|
|\fs|\fsnamequery|Saveafavoritequery.|
|\l|\l|Listdatabases.|
|\once|\o[-o]filename|Appendnextresulttoanoutputfile(overwriteusing-o).|
|\timing|\t|Toggletimingofcommands.|
|connect|\r|Reconnecttothedatabase.Optionaldatabaseargument.|
|exit|\q|Exit.|
|help|\?|Showthishelp.|
|nopager|\n|Disablepager,printtostdout.|
|notee|notee|Stopwritingresultstoanoutputfile.|
|pager|\P[command]|SetPAGER.PrintthequeryresultsviaPAGER.|
|prompt|\R|Changepromptformat.|
|quit|\q|Quit.|
|rehash|\#|Refreshauto-completions.|
|source|\.filename|Executecommandsfromfile.|
|status|\s|Getstatusinformationfromtheserver.|
|system|system[command]|Executeasystemshellcommmand.|
|tableformat|\T|Changethetableformatusedtooutputresults.|
|tee|tee[-o]filename|Appendallresultstoanoutputfile(overwriteusing-o).|
|use|\u|Changetoanewdatabase.|
|watch|watch[seconds][-c]query|Executesthequeryevery[seconds]seconds(bydefault5).|
+-------------+----------------------------+------------------------------------------------------------+
Most commands have a long and short form. Most of the commands are case sensitive. Commands may be followed by an optional semicolon.
-
\GSend the current statement to the server and display the results vertically. This is used instead of a semicolon terminator, e.g.
select 1\G. -
\dt,\dt[+] [table]List the tables in the default database (when used without any parameters). Describe a table (when passed a parameter).
The optional
+verbose indicator can be used to toggle whether or not theCREATE TABLEstatement for the table is shown.The
\dtcommands are equivalent to runningSHOW TABLES,SHOW COLUMNS FROM [table_name], andSHOW CREATE TABLE [table_name]. -
\eEdit the current statement with an editor (uses the environment variable
$EDITOR). If this is entered without a current query, it will populate the editor with the previous query. -
\f,\f [name] [args..]List or execute favorite queries. If the favorite query requires parameters, they can be passed to the query after the name, e.g.,
\f users_by_name "Teddy Roosevelt". See Favorite Queries for more information. -
\fd [name]Delete a favorite query.
-
\fs [name] [query]Save a favorite query. Favorite queries support shell-style parameter substitution. See Favorite Queries for more information.
-
\lList the databases on the MySQL server host. This is equivalent to running
SHOW DATABASES. -
once,\o [-o] filenameOutput the next query's results to an output file. Defaults to append mode. Use
-oto overwrite any existing file content. -
timing,\tToggle whether or not the time it takes to execute a statement is displayed below the results.
-
connect,\rReconnect to the server. You can optionally supply a database name that will be set as the default database for your connection.
-
quit,exit,\qExit mycli.
-
help,\?,?Display a help message listing mycli's commands.
-
nopager,\nDisable the use of pager software for outputting query results. For more information see the pager section of the documentation.
-
noteeDisables the output to the tee file. For more information, see the
teecommand. -
pager,\P [command]Enable the use of a pager for outputting query results. Optionally, specify a command that will be used as the pager. For more information see the pager section of the documentation.
-
prompt,\R [format]Change the prompt format. The default is
\t \u@\h:\d>. See the prompt page of the documentation for more information. -
rehash,\#Refreshes the cached auto-completion data. This is the list of databases, tables, columns that auto-complete when you are typing.
-
source,\. [filename]Executes the SQL commands from the named file.
-
status,\sDisplays status information about the client machine, server, and connection you are using.
-
system,system [command]Executes a shell command and outputs the results.
-
tableformat,\T [format]Change the output format. Run the command without specifying a format to see the possible values.
-
tee,tee [-o] filenameLog all queries/commands and their output to
filename. Defaults to append mode. Use-oto overwrite any existing file content. To disable this, see thenoteecommand. -
use [db_name],\u [db_name]Use
db_nameas the default database. -
watch,watch [seconds] [-c] queryRepeatedly execute a query every
Nseconds. The default interval is5seconds.-ccan be used to clear the screen after every iteration.