Commands
Introduction
Mycli sends most input you enter directly to the MySQL server as a SQL
statement. There is also a set of commands that mycli itself will accept
locally. To see these commands, type /help or /? at the prompt:
mycli> /help
┌─────────────────┬────────┬──────────────────────────────┬──────────────────────────────────────────────────┐
│ Command │ Alias │ Usage │ Description │
├─────────────────┼────────┼──────────────────────────────┼──────────────────────────────────────────────────┤
│ /bug │ <null> │ /bug │ File bug on GitHub. │
│ /clip │ <null> │ /clip | <query>\clip │ Copy query to system clipboard. │
│ /config │ <null> │ /config <command> [key] │ Inspect config file settings (/config help). │
│ /connect │ /r │ /connect [database] │ Reconnect to server, optionally switching dbs. │
│ /delimiter │ <null> │ /delimiter <string> │ Set end-of-statement delimiter. │
│ /dsn │ <null> │ /dsn <command> │ Manage saved DSNs (/dsn help). │
│ /dt │ <null> │ /dt[+] [table] │ List or describe tables. │
│ /edit │ /e │ /edit <file> | <query>\edit │ Edit query with editor (via $VISUAL/$EDITOR). │
│ /exit │ /q │ /exit │ Exit. │
│ /f │ <null> │ /f [name [args] [--key=val]] │ Run favorite query shortcut. │
│ /favorite │ <null> │ /favorite <command> │ Manage favorite queries (/favorite help). │
│ /fd │ <null> │ /fd <name> │ Delete favorite query shortcut. │
│ /fs │ <null> │ /fs <name> <query> │ Save favorite query shortcut. │
│ \g │ <null> │ <query>\g │ Display results (mnemonic: go). │
│ \G │ <null> │ <query>\G │ Display results vertically. │
│ /help │ /? │ /help [term] │ Show this table, or search for help on term. │
│ /l │ <null> │ /l │ List databases. │
│ /llm │ /ai │ /llm [arguments] │ Interrogate LLM (/llm help). │
│ /nopager │ /n │ /nopager │ Disable pager; print to stdout. │
│ /notee │ <null> │ /notee │ Stop writing all results to tee file. │
│ /nowarnings │ /w │ /nowarnings │ Disable automatic warnings display. │
│ /once │ /o │ /once [-o] <file> │ Append next result to a file (-o to overwrite). │
│ /pager │ /P │ /pager [command] │ Set pager to [command]; print results via pager. │
│ /ping │ <null> │ /ping │ Check connection. │
│ /pipe_once │ /| │ /pipe_once <command> │ Send next result to subprocess. │
│ /prompt │ /R │ /prompt [string] │ Set or show prompt format. │
│ /quit │ /q │ /quit │ Quit. │
│ /redirectformat │ /Tr │ /redirectformat <format> │ Set table format used for redirected results. │
│ /rehash │ /# │ /rehash │ Refresh completions. │
│ /source │ /. │ /source [options] <file> │ Execute queries from file. │
│ /status │ /s │ /status │ Get status information from server. │
│ /system │ <null> │ /system [-r] <command> │ Execute shell command (-r for raw mode). │
│ /tableformat │ /T │ /tableformat <format> │ Set table format used for interactive results. │
│ /tee │ <null> │ /tee [-o] <file> │ Append all results to file (-o to overwrite). │
│ /timing │ /t │ /timing │ Toggle query timing. │
│ /use │ /u │ /use <database> │ Change to a new database. │
│ /warnings │ /W │ /warnings │ Enable automatic warnings display. │
│ /watch │ <null> │ /watch [sec] [-c] <query> │ Execute query every [sec] seconds (default 5). │
│ \x │ <null> │ <query>\x │ Display results in an interactive explorer. │
└─────────────────┴────────┴──────────────────────────────┴──────────────────────────────────────────────────┘
Use \backslash forms when at end-of-line.
Docs index — https://mycli.net/docs
Most commands have a long and short form. Many of the commands starting with backslash are case sensitive. Most command lines may be followed by an optional semicolon.
-
Open a browser window to GitHub Issues to report a bug with mycli.
-
Send the current statement to the system clipboard. This is used at the beginning or end of a statement, e.g.
SELECT 1\clip. At the end of a statement, the backslash form\clipmust be used to avoid a SQL ambiguity. -
Inspect configuration settings. See
/config help. It is not yet possible to save settings via this interface. -
/connect [database],/r [database]Reconnect to the server. You can optionally supply a database name which will be set as the default database for your connection.
-
Set the SQL end-of-statement delimiter, which is
;by default. Some mycli functionality may depend on the delimiter being;. -
Manage saved DSNs, including saving the current connection under an alias. See
/dsn help. -
List the tables in the default database (when used without any parameters). Describe a table (when a parameter is passed).
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]. -
/edit <filename>,<query>\editEdit the current statement with an editor (uses the environment variables
$EDITORor$VISUAL), or open a file. If this is entered with an empty line, it will populate the editor with the previous query. At the end of a statement, the backslash form\editmust be used to avoid a SQL ambiguity./editis generally equivalent to the keystroke sequence control-x control-e. -
List or execute named 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. -
Alternative interface for favorite queries, with additional functionality such as
/favorite eval. See/favorite help. -
Delete a favorite query.
-
Save a favorite query. Favorite queries support shell-style parameter substitution. See Favorite Queries for more information.
-
Send the current statement to the server and display the results in the default format. This is used instead of a semicolon terminator, e.g.
SELECT 1\g. -
Send the current statement to the server and display the results vertically. This is used instead of a semicolon terminator, e.g.
SELECT 1\G. -
Display a help message listing mycli's commands. If optional
nameis given and it is a mycli/command, display help on command. Ifnameis not a mycli/commandearch for help fornameon the server. -
List the databases on the MySQL server host. This is equivalent to running
SHOW DATABASES. -
Interact with an LLM using natural language. See Using the /llm Command.
-
Disable the use of an external pager for outputting query results. For more information see the pager section of the web documentation.
-
Disable output to a tee file. For more information, see the
/teecommand. -
Disable automatic display of MySQL warnings from the server. For more information, see the
/warningscommand. -
/once <filename>,/o [-o] <filename>Output the next query's results to an output file. Defaults to append mode. Use
-oto overwrite any existing file content. Also consider using shell-style redirects$> <filename>or$>> <filename>after your SQL statement. -
/pager [command],/P [command]Enable the use of a pager for outputting query results, by default
less. Optionally, specify a different command that will be used as the pager. For more information see the pager section of the web documentation. The default pager may be set in your~/.myclircfile. -
Check whether the connection to the server is live, without running a query.
-
/pipe_once <command>,/| <command>Output the next query's results to a shell command. Also consider using the shell-style redirect
$| <commandafter your SQL statement, as inSELECT 1 $| wc;. -
Change the prompt format. The default is
\t \u@\h:\d>. See the prompt documentation for more information. -
Exit mycli.
-
/redirecformat [format],/Tr [format]Change the output format for shell-style redirections. Run the command without specifying a format to see the possible values. The default is
csv. -
Refresh the cached auto-completion data. (This is the list of databases, tables, columns that auto-complete when you are typing.)
-
/source <filename>,/. <filename>Execute the SQL commands from
<filename>. -
Display status information about the client machine, server, and connection you are using.
-
Execute a shell command and output the results.
-rrequests raw mode, in which output is passed through without formatting.A few commands are special-cased.
If the command is in the form
/system cd <directory>, change the working directory for mycli.If the command is
/system clear, do not show timings after the command.The following commands are assumed to be in raw mode:
vim,vi,bash, andzsh. -
/tableformat [format],/T [format]Change the interactive tabular output format. Run the command without specifying a format to see the possible values.
-
Log all queries/commands and their output to
filename. Defaults to append mode. Use-oto overwrite any existing file content. To disable, see the/noteecommand. -
Toggle whether or not the time it takes to execute a statement is displayed below the results.
-
Use
db_nameas the default database. -
Enable automatic display of MySQL warnings from the server. This is the equivalent of running
SHOW WARNINGSafter every statement. -
Repeatedly execute a query every
nseconds. The default interval is 5 seconds.-ccan be used to clear the screen after each iteration. -
Send the current statement to the server and display the results in an interactive explorer rather than the default pager. This is used instead of a semicolon terminator, e.g.
SELECT * FROM employees\x.