MySQL Shell provides commands which enable you to modify the
execution environment of the code editor, for example to configure
the active programming language or a MySQL Server connection. The
following table lists the commands that are available regardless
of the currently selected language. As commands need to be
available independent of the execution mode,
they start with an escape sequence, the
Print help about MySQL Shell, or search the online help.
Exit MySQL Shell.
In SQL mode, begin multiple-line mode. Code is cached and executed when an empty line is entered.
Show the current MySQL Shell status.
Switch execution mode to Python.
Switch execution mode to SQL.
Connect to a MySQL Server.
Reconnect to the same MySQL Server.
Specify the schema to use.
Execute a script file using the active language.
Show any warnings generated by a statement.
Do not show any warnings generated by a statement.
View and edit command line history.
Manually update the autocomplete name cache.
Query and change MySQL Shell configuration options.
\help command can be used with or without
a parameter. When used without a parameter a general help
message is printed including information about the available
MySQL Shell commands, global objects and main help categories.
When used with a parameter, the parameter is used to search the available help based on the mode which the MySQL Shell is currently running in. The parameter can be a word, a command, an API function, or part of an SQL statement. The following categories exist:
AdminAPI- introduces the
dbaglobal object and the InnoDB cluster AdminAPI.
Shell Commands- provides details about the available built-in MySQL Shell commands.
ShellAPI- contains information about the
utilglobal objects, as well as the
mysqlmodule that enables executing SQL on MySQL Servers.
SQL Syntax- entry point to retrieve syntax help on SQL statements.
X DevAPI- details the
mysqlxmodule as well as the capabilities of the X DevAPI which enable working with MySQL as a Document Store
To search for help on a topic, for example an API function, use
the function name as a
can use the wildcard characters
? to match
any single character and
* to match multiple
characters in a search. The wildcard characters can be used one
or more times in the pattern. The following namespaces can also
be used when searching for help:
mysqlxfor X DevAPI
mysqlfor ShellAPI for classic protocol
shellfor other ShellAPI classes:
commandsfor MySQL Shell commands
cmdlinefor the mysqlsh command interface
For example to search for help on a topic, issue
x devapito search for help on the X DevAPI
\cto search for help on the MySQL Shell
dba.Clusterto search for help on the AdminAPI
mysqlx.Tableto search for help on the X DevAPI
mysqlx.Table.isViewto search for help on the
isViewfunction of the
when MySQL Shell is running in Python mode, use
mysqlx.Table.is_viewto search for help on the
isViewfunction of the
when MySQL Shell is running in SQL mode, if a global session to a MySQL server exists SQL help is displayed. For an overview use
sql syntaxas the search pattern.
Depending on the search pattern provided one or more results could be found. If a single topic matches the pattern searched for, the help is displayed. If multiple topics match the pattern searched for a list of possible help topics is displayed, and you can view the topic using the search pattern displayed.
\connect command is used to connect to a
MySQL Server using an URI type string. See
Connecting using a URI String.
If a password is required you are prompted for it.
option to create a session using the X Protocol to connect
to MySQL server instance. For example:
\connect --mysqlx root@localhost:33060
option to create a ClassicSession, enabling you to use the MySQL
protocol to issue SQL directly on a server. For example:
\connect --mysql root@localhost:3306
The use of a single dash with the short form options (that is,
-mc) is deprecated
from version 8.0.13 of MySQL Shell.
\reconnect command is specified without
any parameters or options. If the connection to the server is
lost, you can use the
which makes MySQL Shell try several reconnection attempts for
the session using the existing connection parameters. If those
attempts are unsuccessful, you can make a fresh connection using
\connect command and specifying the
\status command displays information
about the current global connection. This includes information
about the server connected to, the character set in use, uptime,
and so on.
\source command is used to execute code
from a script at a given path. For example:
As the code is executed using the active language, executing a script in a different language than the currently selected execution mode language could lead to unexpected results.
\use command enables you to choose which
schema is active, for example:
\use command requires a global
development session to be active. The
command sets the current schema to the specified
schema_name and updates the
db variable to the object that represents the
\history command lists the commands you
have issued previously in MySQL Shell. Issuing
\history shows history entries in the order
that they were issued with their history entry number, which can
be used with the
\history command provides the following
\history saveto save the history manually.
\history delete entrynumberto delete the individual history entry with the given number.
\history deleteto delete history entries within the range of the given entry numbers. If
goes past the last found history entry number, history entries are deleted up to and including the last entry.
\history deleteto delete the history entries from
up to and including the last entry.
\history delete -to delete the specified number of history entries starting with the last entry and working back. For example,
\history delete -10deletes the last 10 history entries.
\history clearto delete the entire history.
For more information, see Section 4.4, “MySQL Shell Code History”.
When you have disabled the autocomplete name cache feature, use
\rehash command to manually update the
cache. For example, after you load a new schema by issuing the
\rehash to update the
autocomplete name cache. After this autocomplete is aware of the
names used in the database, and you can autocomplete text such
as table names and so on. See
Section 4.3, “Code Autocompletion”.
\option command enables you to query and
change MySQL Shellconfiguration options in all modes. You can
\option command to list the
configuration options that have been set and show how their
value was last changed. You can also use it to set and unset
options, either for the session, or persistently in the
MySQL Shell configuration file. For instructions and a list of
the configuration options, see
Section 8.4, “Configuring MySQL Shell”.