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 | Shortcut | Usage | Description |
+-----------------+----------+---------------------------------+-------------------------------------------------------------+
| /bug | <null> | /bug | File a bug on GitHub. |
| /clip | <null> | /clip | <query>\clip | Copy query to the system clipboard. |
| /dt | <null> | /dt[+] [table] | List or describe tables. |
| /edit | /e | /edit <filename> | <query>\edit | Edit query with editor (uses $VISUAL or $EDITOR). |
| /f | <null> | /f [name [args..]] | List or execute favorite queries. |
| /fd | <null> | /fd <name> | Delete a favorite query. |
| /fs | <null> | /fs <name> <query> | Save a favorite query. |
| \g | <null> | <query>\g | Display query results (mnemonic: go). |
| \G | <null> | <query>\G | Display query results vertically. |
| /l | <null> | /l | List databases. |
| /llm | /ai | /llm [arguments] | Interrogate an LLM. See "/llm help". |
| /once | /o | /once [-o] <filename> | Append next result to an output file (overwrite using -o). |
| /pipe_once | /| | /pipe_once <command> | Send next result to a subprocess. |
| /timing | /t | /timing | Toggle timing of queries. |
| /connect | /r | /connect [database] | Reconnect to the server, optionally switching databases. |
| /delimiter | <null> | /delimiter <string> | Change end-of-statement delimiter. |
| /exit | /q | /exit | Exit. |
| /help | /? | /help [term] | Show this table, or search for help on a term. |
| /nopager | /n | /nopager | Disable pager; print to stdout. |
| /notee | <null> | /notee | Stop writing results to an output file. |
| /nowarnings | /w | /nowarnings | Disable automatic warnings display. |
| /pager | /P | /pager [command] | Set pager to [command]. Print query results via pager. |
| /prompt | /R | /prompt <string> | Change prompt format. |
| /quit | /q | /quit | Quit. |
| /redirectformat | /Tr | /redirectformat <format> | Change the table format used to output redirected results. |
| /rehash | /# | /rehash | Refresh auto-completions. |
| /source | /. | /source <filename> | Execute queries from a file. |
| /status | /s | /status | Get status information from the server. |
| /system | <null> | /system [-r] <command> | Execute a system shell command (raw mode with -r). |
| /tableformat | /T | /tableformat <format> | Change the table format used to output interactive results. |
| /tee | <null> | /tee [-o] <filename> | Append all results to an output file (overwrite using -o). |
| /use | /u | /use <database> | Change to a new database. |
| /warnings | /W | /warnings | Enable automatic warnings display. |
| /watch | <null> | /watch [seconds] [-c] <query> | Execute query every [seconds] seconds (5 by default). |
+-----------------+----------+---------------------------------+-------------------------------------------------------------+
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 are case sensitive. Most commands may be followed by an optional semicolon.
-
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. -
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 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. -
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. -
Delete a favorite query.
-
Save a favorite query. Favorite queries support shell-style parameter substitution. See Favorite Queries for more information.
-
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.
-
/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. -
/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;. -
Toggle whether or not the time it takes to execute a statement is displayed below the results.
-
/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;. -
Exit mycli.
-
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. -
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. -
/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. -
Change the prompt format. The default is
\t \u@\h:\d>. See the prompt documentation for more information. -
/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. As a special case, if the command is in the form
cd <directory, change the working directory for mycli. -
/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. -
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.