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 \
character.
| Command | Alias/Shortcut | Description |
|---|---|---|
|
| Prints help about MySQL Shell commands. |
|
| 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 JavaScript. | |
| Switch execution mode to Python. | |
| Switch execution mode to SQL. | |
|
| Connect to a MySQL Server with a URI using an XSession (X Protocol). |
|
|
(Removed in version 1.0.4, use |
|
|
(Removed in version 1.0.4, use |
| 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. |
|
| Print the connection data for the stored sessions. |
|
|
Save connection data of a session, optionaly use
|
|
|
(Removed in version 1.0.4, see
|
| Removes a stored session. | |
|
(Removed in version 1.0.4, see
|
The \help command can be used with or without
parameters. When used without parameters a general help is
printed including information about:
Available commands.
Available commands for the active mode.
When used with a parameter, the parameter must be a valid command. If that is the case, help for that specific command is printed including:
Description
Supported aliases if any
Additional help if any
For example:
\help connectIf the parameter is not a valid command, the general help is printed.
The \connect command is used to connect to a
MySQL Server using an URI. This command creates an
X Protocol connection by default.
For example:
\connect root@localhost:3306If a password is required you are prompted for it.
Use the -n option to create a Node session,
using the X Protocol to connect to a single server. For
example:
\connect -n root@localhost:3306
Use the -c option to create a Classic
session, enabling you to use the MySQL Protocol to issue SQL
commands directly on a server. For example:
\connect -c root@localhost:3306
The \source command is used to execute code
from a script at a given path. For example:
\source /tmp/mydata.sqlIt can be used to execute either SQL, JavaScript or Python code. The code in the file is executed using the active language, so to process SQL code the MySQL Shell must be in SQL mode.
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.
The \use command enables you to choose which
schema is active, for example:
\use schema_name
The \use command requires a global
development session to be active. If the global development
session is an XSession then the \use command
only sets db to the object representing the
schema_name but does not set a
current schema on the database. If the global development
session is one of NodeSession or ClassicSession the
\use command sets the current schema to the
specified schema_name and updates the
db variable to the object that represents the
selected schema.