MySQL Shell is an advanced command-line client and code editor for MySQL. In addition to SQL, MySQL Shell also offers scripting capabilities for JavaScript and Python. For information about using MySQL Shell, see MySQL Shell 9.5. When MySQL Shell is connected to the MySQL Server through the X Protocol, the X DevAPI can be used to work with both relational and document data, see Using MySQL as a Document Store. MySQL Shell includes the AdminAPI that enables you to work with InnoDB Cluster, InnoDB ClusterSet, and InnoDB ReplicaSet deployments; see Chapter 6, MySQL AdminAPI.
Many of the options described here are related to connections between MySQL Shell and a MySQL Server instance. See Section 4.3, “MySQL Shell Connections” for more information.
mysqlsh supports the following command-line options.
Table A.1 mysqlsh Options
| Option Name | Description |
|---|---|
| -- | Start of API command line integration |
| --auth-method | Authentication method to use |
| --authentication-oci-client-config-profile | Profile in the OCI configuration file |
| --authentication-openid-connect-client-id-token-file | The file path to an OpenId Connect authorization token file |
| --cluster | Connect to an InnoDB cluster |
| --column-type-info | Print metadata for columns in result sets |
| --compress | Compress all information sent between client and server |
| --compression-algorithms | Permitted compression algorithms for connections to server |
| --zstd-compression-level | Compression level for connections to server that use any compression algorithm over X Protocol or for zstd only on classic connections. |
| --connect-timeout | Connection timeout for global session |
| --credential-store-helper | The Secret Store helper for passwords |
| --database | The schema to use (alias for --schema) |
| --dba | Enable X Protocol on connection with MySQL 5.7 server |
| --dba-log-sql | Log SQL statements that are executed by AdminAPI operations |
| --disable-plugins | Disable loading user plugins |
| --execute | Execute the command and quit |
| --file | File to process in batch mode |
| --force | Continue in SQL and batch modes even if errors occur |
| --get-server-public-key | Request RSA public key from server |
| --help | Display help message and exit |
| --histignore | Strings that are not added to the history |
| --host | Host on which MySQL server instance is located |
| --interactive | Emulate Interactive mode in batch mode |
| --js, --javascript | Start in JavaScript mode |
| --json | Print output in JSON format |
| --local-infile | Whether LOCAL is supported for LOAD DATA statements in the client. Must be defined on server also |
| --log-file | Log file location for this instance |
| --log-level | Specify logging level |
| --log-sql | Log all MySQL Shell-generated SQL statements to the MySQL Shell log file. |
| --mysql, --mc | Create a session using classic MySQL protocol |
| --mysql-plugin-dir | Directory where the client-side plugins are installed |
| --mysqlx, --mx | Create a session using X Protocol |
| --name-cache | Enable automatic loading of table names based on the active default schema |
| --no-name-cache | Disable autocompletion |
| --no-password | No password is provided for this connection |
| --no-wizard, --nw | Disable the interactive wizards |
| --oci-config-file | Path to the OCI configuration file to use |
| --pager | The external pager tool used to display output |
| --password | Password to use when connecting to server |
| --password1 | Password 1 for multifactor authentication (equivalent to --password) |
| --password2 | Password 2 for multifactor authentication |
| --password3 | Password 3 for multifactor authentication |
| --passwords-from-stdin | Read the password from stdin |
| --plugin-authentication-kerberos-client-mode | Allows defining the kerberos client mode (SSPI or GSSAPI) when using kerberos authentication |
| --plugin-authentication-webauthn-client-preserve-privacy | Enable user to choose a key to be used for assertion |
| --plugin-authentication-webauthn-device | Specifies which libfido2 device to use. Default is 0 (first device) |
| --port | TCP/IP port number for connection |
| --py, --python | Start in Python mode |
| --pyc | Execute a Python command and quit. Any options specified after this are treated as arguments of the processed command. |
| --pym | Password 3 for multifactor authentication |
| --quiet-start | Start without printing introductory information |
| --redirect-primary | Ensure connection to an InnoDB cluster's primary |
| --redirect-secondary | Ensure connection to an InnoDB cluster's secondary |
| --register-factor | Multifactor authentication factors for which registration must be done |
| --replicaset | Ensures that the target server belongs to an InnoDB ReplicaSet, and populates the rs global variable with the InnoDB ReplicaSet the target instance belongs to |
| --result-format | Set the output format for this session |
| --save-passwords | How passwords are stored in the Secret Store |
| --schema | The schema to use |
| --server-public-key-path | Path name to file containing RSA public key |
| --show-warnings | Show warnings after each statement if there are any (in SQL mode) |
| --socket | Unix socket file or Windows named pipe to use (classic MySQL protocol only) |
| --sql | Start in SQL mode, auto-detecting protocol to use for connection |
| --sqlc | Start in SQL mode using a classic MySQL protocol connection |
| --sqlx | Start in SQL mode using an X Protocol connection |
| --ssh | URI for connection to SSH server |
| --ssh-config-file | Configuration file for connection to SSH server |
| --ssh-identity-file | Identity file for connection to SSH server |
| --ssl-ca | File that contains list of trusted SSL Certificate Authorities |
| --ssl-capath | Directory that contains trusted SSL Certificate Authority certificate files |
| --ssl-cert | File that contains X.509 certificate |
| --ssl-cipher | List of permissible encryption ciphers for connections that use TLS protocols up through TLSv1.2 |
| --ssl-crl | File that contains certificate revocation lists |
| --ssl-crlpath | Directory that contains certificate revocation list files |
| --ssl-key | File that contains X.509 key |
| --ssl-mode | Desired security state of connection to server |
| --syslog | Log interactive SQL statements to the system logging facility |
| --tabbed | Display output in tab separated format |
| --table | Display output in table format |
| --tls-ciphersuites | TLS v1.3 cipher to use |
| --tls-version | Permissible TLS protocol for encrypted connections |
| --uri | Session information in URI format |
| --user | MySQL user name to use when connecting to server |
| --verbose | Activate verbose output to the console |
| --version | Display version information and exit |
| --vertical | Display all SQL results vertically |
| --zstd-compression-level | Compression level for connections to server that use zstd compression |
-
--help,-?Display a help message and exit.
-
Marks the end of the list of mysqlsh options and the start of a command and its arguments for MySQL Shell's API command line integration. You can execute methods of the MySQL Shell global objects from the command line using this syntax:
mysqlsh [options] -- object method [arguments]See Section 5.8, “API Command Line Integration” for more information.
-
Authentication method to use for the account. Depends on the authentication plugin used for the account's password. For MySQL Shell connections using classic MySQL protocol, specify the name of the authentication plugin, for example
caching_sha2_password. For MySQL Shell connections using X Protocol, specify one of the following options:- AUTO
Let the library select the authentication method.
- FALLBACK
Let the library select the authentication method, but do not use any authentication method that is not compatible with MySQL 5.7.
- FROM_CAPABILITIES
Let the library select the authentication method, using the capabilities announced by the server instance.
- MYSQL41
Use the challenge-response authentication protocol supported by MySQL 4.1 and later, which does not send a plaintext password. This option is compatible with accounts that use the
mysql_native_passwordauthentication plugin.- PLAIN
Send a plaintext password for authentication. Use this option only with encrypted connections. This option can be used to authenticate with cached credentials for an account that uses the
caching_sha2_passwordauthentication plugin, provided there is an SSL connection. See Using X Plugin with the Caching SHA-2 Authentication Plugin.- SHA256_MEMORY
Authenticate using a hashed password stored in memory. This option can be used to authenticate with cached credentials for an account that uses the
caching_sha2_passwordauthentication plugin, where there is a non-SSL connection. See Using X Plugin with the Caching SHA-2 Authentication Plugin.
For MySQL Shell connections using classic MySQL protocol, specify the name of the authentication plugin used by the user account, for example
caching_sha2_password(which is the default for user accounts created in MySQL 8.0). MySQL Shell uses the MySQL client library for client-side authentication for these connections. The following authentication methods require additional configuration:- clear_text_password
The
mysql_clear_passwordclient-side plugin is required for simple LDAP authentication. It is built in to the MySQL client library, but for security it is not enabled by default. MySQL Shell enables and uses the plugin when you specify it with the--auth-method=clear_text_passwordconnection option. This authentication type is only suitable for a secure connection that uses SSL or sockets, so you must configure the secure connection before using it. Note that with the optionssl-mode=preferred, the SSL connection is not guaranteed, so a connection with this option set is not considered to be an SSL connection. For more information, see Section 4.3.4, “Using Encrypted Connections”.- authentication_ldap_sasl_client
The
authentication_ldap_sasl_clientclient-side plugin is for SASL-based LDAP authentication, including GSSAPI/Kerberos authentication. It is not built in to the MySQL client library, but it is shipped in the MySQL Server packages. To load it, you must use the--mysql-plugin-diroption to specify a path to the plugin in the MySQL Server packages.- authentication_kerberos_client
The
authentication_kerberos_clientclient-side plugin is for Kerberos authentication. It is not built in to the MySQL client library, but it is shipped in the MySQL Server packages. To load it, you must use the--mysql-plugin-diroption to specify a path to the plugin in the MySQL Server packages.
Cached ticket-granting tickets (TGTs) for Kerberos authentication are supported from MySQL 8.0.27 when the
--auth-methodoption is used to specify theauthentication_ldap_sasl_clientorauthentication_kerberos_clientplugin, and the--mysql-plugin-diroption is used to provide a path to the plugin. To use cached TGTs, do not specify a user and password in the connection options. When you specify one of these plugins and do not specify a user and password, MySQL Shell does not supply the system user name, does not prompt for a password, and does not attempt to use the Secret Store helper to retrieve or store credentials.For more information, see Section 4.3.5, “Using LDAP and Kerberos Authentication”.
-
Ensures that the target server is part of an InnoDB Cluster and if so, sets the
clusterglobal variable to the cluster object. -
In SQL mode, before printing the returned result set for a query, print metadata for each column in the result set, such as the column type and collation.
The column type is returned as both the type used by MySQL Shell (
Type), and the type used by the original database (DBType). For MySQL Shell connections using classic MySQL protocol,DBTypeis as returned by the protocol, and for X Protocol connections,DBTypeis inferred from the available information. The column length (Length) is returned in bytes. -
--compress[={required|preferred|disabled}],-C [{required|preferred|disabled}]Controls compression of information sent between the client and the server using this connection. It is also available for classic MySQL protocol and X Protocol connections, and you can optionally specify
required,preferred, ordisabled. When just--compressis specified, the value defaults to--compress=required. See Section 4.3.8, “Using Compressed Connections” for information on using MySQL Shell's compression control in all releases. -
--compression-algorithms=valueCommand-Line Format --compression-algorithms=valueType Set Default Value uncompressedValid Values zlibzstduncompressedThe permitted compression algorithms for connections to the server.
-
Command-Line Format --zstd-compression-level=#Type Integer Compression level for connections to server that use any compression algorithm over X Protocol or for zstd only on classic connections.
-
--zstd-compression-level=levelCommand-Line Format --zstd-compression-level=#Type Integer The compression level to use for connections to the server that use the
zstdcompression algorithm. The permitted levels are from 1 to 22, with larger values indicating increasing levels of compression. The defaultzstdcompression level is 3. The compression level setting has no effect on connections that do not usezstdcompression. -
Configures how long MySQL Shell waits (in milliseconds) to establish a global session specified through command-line arguments.
-
--credential-store-helper=helperThe Secret Store Helper that is to be used to store and retrieve passwords. See Section 4.4, “Pluggable Password Store”.
-
--database=,name-DnameThe default schema to use. This is an alias for
--schema. -
Disables user plugins.
-
This variable controls client-side LOCAL capability for LOAD DATA statements.
The following options are available:
- OFF
(Default) It is not possible to use
LOAD DATA LOCAL INFILEstatements.- ON
It is possible to use
LOAD DATA LOCAL INFILEstatements, if the server has been configured to permit them.
-
--log-sql[=off|error|on|all|unfiltered]Log all SQL statements executed by MySQL Shell to the MySQL Shell log file,
mysqlsh.logThe following options are available:
- off
No MySQL Shell SQL statements are logged.
- error
(Default value) only MySQL Shell failed SQL statements with are logged.
- on
All MySQL Shell SQL statements are logged, except those which match the ignore pattern defined in
logSql.ignorePatternandlogSql.ignorePatternUnsafe. See Filtering SQL Logging for more information.- all
All MySQL Shell SQL statements are logged, except those which match the ignore pattern defined in
logSql.ignorePatternUnsafe. See Filtering SQL Logging for more information.- unfiltered
All MySQL Shell SQL statements are logged, no filtering is performed.
-
--execute=,command-ecommandExecute the command using the currently active language and quit. This option is mutually exclusive with the
--file=option.file_name -
--file=,file_name-ffile_nameSpecify a file to process in Batch mode. Any options specified after this are used as arguments of the processed file.
-
Continue processing in SQL and Batch modes even if errors occur.
-
Specify strings that are not added to the MySQL Shell history. Strings are separated by a colon. Matching is case insensitive, and the wildcards * and ? can be used. The default ignored strings are specified as “
*IDENTIFIED*:*PASSWORD*”. See Section 5.5, “Code History”. -
--host=,host_name-hhost_nameConnect to the MySQL server on the given host. On Windows, if you specify
--host=.or-h .(giving the host name as a period), MySQL Shell connects using the default named pipe (which has the nameMySQL), or an alternative named pipe that you specify using the--socketoption. -
MySQL Shell equivalent of
--get-server-public-key.If
--server-public-key-path=is given and specifies a valid public key file, it takes precedence overfile_name--get-server-public-key.ImportantOnly supported with classic MySQL protocol connections.
-
Emulate Interactive mode in Batch mode.
-
--js,--javascriptStart in JavaScript mode.
-
Controls JSON wrapping for MySQL Shell output from this session. This option is intended for interfacing MySQL Shell with other programs, for example as part of testing. For changing query results output to use the JSON format, see
--result-format.When the
--jsonoption has no value or a value ofpretty, the output is generated as pretty-printed JSON. With a value ofraw, the output is generated in raw JSON format. In any of these cases, the--result-formatoption and its aliases and the value of theresultFormatMySQL Shell configuration option are ignored. With a value ofoff, JSON wrapping does not take place, and result sets are output as normal in the format specified by the--result-formatoption or theresultFormatconfiguration option. -
Change the location of the MySQL Shell application log file
mysqlsh.logfor this MySQL Shell instance. The default location for the application log file is the user configuration path, which defaults to%APPDATA%\MySQL\mysqlsh\on Windows or~/.mysqlsh/on Unix. You can override the user configuration path for all MySQL Shell instances by defining the environment variableMYSQLSH_USER_CONFIG_HOME. The--log-fileoption applies to the individual MySQL Shell instance, meaning that different instances can write to different locations. -
Change the logging level for the MySQL Shell application log file
mysqlsh.log, or disable logging to the file. The option requires a value, which can be either an integer in the range from 1 to 8, or one ofnone,internal,error,warning,info,debug,debug2, ordebug3. Specifying 1 ornonedisables logging to the application log file. Level 5 (info) is the default if you do not specify this option. See Chapter 13, MySQL Shell Logging and Debug. -
--mysql,--mcSets the global session created at start up to use a classic MySQL protocol connection.
-
Sets a non-persistent path to the client-side authentication plugins by overriding the value of the
shell.options.mysqlPluginDirsetting. Client-side plugins are shipped in the MySQL Server packages and can be located relative to the MySQL base directory (the value of thebasedirsystem variable). For example:C:\program files\mysql\mysql Server 8.0\lib\pluginon Windows host types/usr/local/mysql/lib/pluginon Linux host types
For a list of the client authentication plugins that ship with the server, see Available Authentication Plugins.
-
--mysqlx,--mxSets the global session created at start up to use an X Protocol connection.
-
Enable automatic loading of table names based on the active default schema.
-
--no-name-cache,-ADisable loading of table names for autocompletion based on the active default schema and the DevAPI
dbobject. Use\rehashto reload the name information manually. -
When connecting to the server, if the user has a passwordless account, which is insecure and not recommended, or if socket peer-credential authentication is in use (for Unix socket connections), you must use
--no-passwordto explicitly specify that no password is provided and the password prompt is not required. -
--no-wizard,-nwDisables the interactive wizards provided by operations such as creating connections,
dba.configureInstance(),and so on. Use this option when you want to script MySQL Shell and not have the interactive prompts displayed. For more information see Section 5.6, “Batch Code Execution” and Section 5.8, “API Command Line Integration”.Cluster.rebootClusterFromCompleteOutage() -
--oci-config-file=pathToConfigFileConfigures a path to the OCI config file to use with OCI authentication to connect to a MySQL HeatWave Service DB System.
The value defined here overrides the value defined in the
oci.configFileoption.For more information, see Authenticating Using authentication_oci Plugin.
-
--authentication-oci-client-config-profile=profileNameConfigures the profile in the OCI config file to use with OCI authentication to connect to a MySQL HeatWave Service DB System.
The value defined here overrides the value defined in the
oci.profileoption.For more information, see Authenticating Using authentication_oci Plugin.
-
--authentication-openid-connect-client-id-token-file=filenameThe file path to an OpenId Connect authorization token file
See Section 4.3.6, “Using OpenID Connect”.
ImportantOpenID Connect authentication is supported by MySQL Enterprise Edition, only.
-
The external pager tool used by MySQL Shell to display text output for statements executed in SQL mode and other selected commands such as online help. If you do not set a pager, the pager specified by the
PAGERenvironment variable is used. See Section 4.7, “Using a Pager”. -
Read the password from standard input, rather than from the terminal. This option does not affect any other password behaviors, such as the password prompt.
-
--password[=,password]-ppasswordThe password to use when connecting to the server. The maximum password length that is accepted for connecting to MySQL Shell is 128 characters.
-
--password=(password-p) with a value supplies a password to be used for the connection. With the long formpassword--password=, you must use an equals sign and not a space between the option and its value. With the short form-p, there must be no space between the option and its value. If a space is used in either case, the value is not interpreted as a password and might be interpreted as another connection parameter.Specifying a password on the command line should be considered insecure. See End-User Guidelines for Password Security. You can use an option file to avoid giving the password on the command line.
--passwordwith no value and no equal sign, or-pwithout a value, requests the password prompt.--password=with an empty value has the same effect as--no-password, which specifies that the user is connecting without a password. When connecting to the server, if the user has a passwordless account, which is insecure and not recommended, or if socket peer-credential authentication is in use (for Unix socket connections), you must use one of these methods to explicitly specify that no password is provided and the password prompt is not required.
-
-
--password1,--password2and--password3are the passwords to use for accounts that require multifactor authentication. You can supply up to three passwords. The options work in the same way as the--passwordoption, and--password1is treated as equivalent to that option. You can specify a password value following the option on the command line (which is insecure), or if the options are given without a password value, MySQL Shell prompts the user for each password in turn. Only supported for classic MySQL protocol connections made using command-line arguments. -
The password for the second authentication method for accounts that require multifactor authentication. See the description for the
--password1option. -
The password for the third authentication method for accounts that require multifactor authentication. See the description for the
--password1option. -
--plugin-authentication-kerberos-client-mode={SSPI|GSSAPI}Command-Line Format --plugin-authentication-kerberos-client-modeType String Default Value SSPIValid Values SSPIGSSAPIOn Microsoft Windows platforms, allows defining the kerberos client mode (SSPI or GSSAPI) when using kerberos authentication.
If
plugin-authentication-kerberos-client-modeis not defined,SSPIis used by default.When connecting to a MySQL server using Kerberos authentication, the authentication modes have the following behavior:
-
GSSAPI:If a password is not provided, the authentication ticket is retrieved from the MIT Kerberos cache. If a valid ticket cannot be found, the connection fails.
If a password is provided, the authentication ticket is retrieved from the Kerberos server and stored in the MIT Kerberos cache.
If an account name is not provided, the Windows user name is used as the MySQL account name.
-
SSPI:If a password is not provided, the Windows single-sign-on ticket is used.
If a password is provided, the authentication ticket is stored in temporary, in-memory storage.
-
-
--plugin-authentication-webauthn-client-preserve-privacy={OFF|ON}Command-Line Format --plugin-authentication-webauthn-client-preserve-privacyType Boolean Default Value falseDetermines how assertions are sent to server in case there are more than one discoverable credentials stored for a given RP ID (a unique name given to the relying-party server, which is the MySQL server). If the FIDO2 device contains multiple resident keys for a given RP ID, this option allows the user to choose a key to be used for assertion. It provides two possible values that the client user can set. The default value is
false. If set tofalse, the challenge is signed by all credentials available for a given RP ID and all signatures are sent to server. If set totrue, the user is prompted to choose the credential to be used for signature.NoteThis option has no effect if the device does not support the resident-key feature.
For more information, see WebAuthn Pluggable Authentication.
-
--plugin-authentication-webauthn-device=nCommand-Line Format --plugin-authentication-webauthn-deviceType Integer Default Value 0Specifies which libfido2 device to use. Default is 0 (first device). Supported over classic protocol, only.
For more information, see WebAuthn Pluggable Authentication.
-
--port=,port_num-Pport_numThe TCP/IP port number to use for the connection. The default is port 33060.
-
--py,--pythonStart in Python mode.
-
Execute a Python command and quit. Any options specified after this are treated as arguments of the processed command.
-
Execute the specified Python module as a script in MySQL Shell's Python mode.
--pymworks in the same way as Python's-mcommand line option. -
Start without printing introductory information. MySQL Shell normally prints information about the product, information about the session (such as the default schema and connection ID), warning messages, and any errors that are returned during startup and connection. When you specify
--quiet-startwith no value or a value of 1, information about the MySQL Shell product is not printed, but session information, warnings, and errors are printed. With a value of 2, only errors are printed. -
Ensures that the target server is part of an InnoDB Cluster or InnoDB ReplicaSet and if it is not the primary, finds the primary and connects to it. MySQL Shell exits with an error if any of the following is true when using this option:
No instance is specified
On an InnoDB Cluster, Group Replication is not active
InnoDB Cluster metadata does not exist
There is no quorum
-
Command-Line Format --register-factor=valueType String The factor or factors for which FIDO/FIDO2 device registration must be performed before WebAuthn device-based authentication can be used. This option value must be a single value, or two values separated by commas. Each value must be 2 or 3, so the permitted option values are
'2','3','2,3'and'3,2'.For example, an account that requires registration for a 3rd authentication factor invokes the mysql client as follows:
mysqlsh --user=user_name --register-factor=3An account that requires registration for a 2nd and 3rd authentication factor invokes the mysql client as follows:
mysqlsh --user=user_name --register-factor=2,3If registration is successful, a connection is established. If there is an authentication factor with a pending registration, a connection is placed into pending registration mode when attempting to connect to the server. In this case, disconnect and reconnect with the correct
--register-factorvalue to complete the registration.Registration is a two step process comprising initiate registration and finish registration steps. The initiate registration step executes this statement:
ALTER USER user factor INITIATE REGISTRATIONThe statement returns a result set containing a 32 byte challenge, the user name, and the relying party ID (see
authentication_webauthn_rp_id).The finish registration step executes this statement:
ALTER USER user factor FINISH REGISTRATION SET CHALLENGE_RESPONSE AS 'auth_string'The statement completes the registration and sends the following information to the server as part of the
auth_string: authenticator data, an optional attestation certificate in X.509 format, and a signature.The initiate and registration steps must be performed in a single connection, as the challenge received by the client during the initiate step is saved to the client connection handler. Registration would fail if the registration step was performed by a different connection. The
--register-factoroption executes both the initiate and registration steps, which avoids the failure scenario described above and prevents having to execute theALTER USERinitiate and registration statements manually.The
--register-factoroption is only available for the mysql client. Other MySQL client programs do not support it.For related information, see Using WebAuthn Authentication.
-
Ensures that the target server belongs to an InnoDB ReplicaSet, and if so, populates the
rsglobal variable with the InnoDB ReplicaSet. You can then administer the InnoDB ReplicaSet using thersglobal variable, for example by issuingrs.status(). -
Ensures that the target server is part of a single-primary InnoDB Cluster or InnoDB ReplicaSet and if it is not a secondary, finds a secondary and connects to it. MySQL Shell exits with an error if any of the following is true when using this option:
On an InnoDB Cluster, Group Replication is not active
InnoDB Cluster metadata does not exist
There is no quorum
The cluster is not single-primary and is running in multi-primary mode
There is no secondary available, for example because there is just one server instance
-
--result-format={table|tabbed|vertical|json|json/pretty|ndjson|json/raw|json/array}Set the value of the
resultFormatMySQL Shell configuration option for this session. Formats are as follows:- table
The default for interactive mode, unless another value has been set persistently for the
resultFormatconfiguration option in the configuration file, in which case that default applies. The--tablealias can also be used.- tabbed
The default for batch mode, unless another value has been set persistently for the
resultFormatconfiguration option in the configuration file, in which case that default applies. The--tabbedalias can also be used.- vertical
Produces output equivalent to the
\Gterminator for an SQL query. The--verticalor-Ealiases can also be used.- json or json/pretty
Produces pretty-printed JSON.
- ndjson or json/raw
Produces raw JSON delimited by newlines.
- json/array
Produces raw JSON wrapped in a JSON array.
If the
--jsoncommand line option is used to activate JSON wrapping for output for the session, the--result-formatoption and its aliases and the value of theresultFormatconfiguration option are ignored. -
--save-passwords={always|prompt|never}Controls whether passwords are automatically stored in the secret store.
alwaysmeans passwords are always stored unless they are already in the store or the server URL is excluded by a filter.nevermeans passwords are never stored.prompt, which is the default, means users are asked whether to store the password or not. See Section 4.4, “Pluggable Password Store”. -
--schema=,name-DnameThe default schema to use.
-
--server-public-key-path=file_nameMySQL Shell equivalent of
--server-public-key-path.If
--server-public-key-path=is given and specifies a valid public key file, it takes precedence overfile_name--get-server-public-key.ImportantOnly supported with classic MySQL protocol connections.
See
caching_sha2_passwordplugin Caching SHA-2 Pluggable Authentication. -
When true is specified, which is the default, in SQL mode, MySQL Shell displays warnings after each SQL statement if there are any. If false is specified, warning are not displayed.
-
--socket[=,path]-S[path]On Unix, when a path is specified, the path is the name of the Unix socket file to use for the connection. If you specify
--socketwith no value and no equal sign, or-Swithout a value, the default Unix socket file for the appropriate protocol is used.On Windows, the path is the name of the named pipe to use for the connection. The pipe name is not case-sensitive. On Windows, you must specify a path, and the
--socketoption is available for classic MySQL protocol sessions only.You cannot specify a socket if you specify a port or a host name other than
localhoston Unix or a period (.) on Windows. -
Start in SQL mode, auto-detecting the protocol to use if it is not specified as part of the connection information. When the protocol to use is not specified, defaults to an X Protocol connection, falling back to a classic MySQL protocol connection. To force a connection to use a specific protocol see the
--sqlxor--sqlcoptions. Alternatively, specify a protocol to use as part of a URI-like connection string or use the--portoption. See Section 4.3, “MySQL Shell Connections” and MySQL Shell Ports. for more information. -
Start in SQL mode forcing the connection to use classic MySQL protocol, for example to use MySQL Shell with a server that does not support X Protocol. If you do not specify the port as part of the connection, when you provide this option MySQL Shell uses the default classic MySQL protocol port which is usually 3306. The port you are connecting to must support classic MySQL protocol, so for example if the connection you specify uses the X Protocol default port 33060, the connection fails with an error. See Section 4.3, “MySQL Shell Connections” and MySQL Shell Ports. for more information.
-
Start in SQL mode forcing the connection to use X Protocol. If you do not specify the port as part of the connection, when you provide this option MySQL Shell uses the default X Protocol port which is usually 33060. The port you are connecting to must support X Protocol, so for example if the connection you specify uses the classic MySQL protocol default port 3306, the connection fails with an error. See Section 4.3, “MySQL Shell Connections” and MySQL Shell Ports. for more information.
-
Create an SSH tunnel that provides an encrypted connection to the MySQL server instance. Supply the URI for connection to the SSH server in the format
[user@]host[:port], for example:--ssh root@198.51.100.4:2222When you use this option, you must also specify the
--user,--host, and--portoptions, or a URI, for connection to the MySQL server instance. For information on SSH tunnel connections from MySQL Shell, see Section 4.3.7, “Using an SSH Tunnel”. -
Specify the path to an SSH configuration file for the connection to the SSH server. You can use the MySQL Shell configuration option
ssh.configFileto set a custom file as the default if this option is not specified. Ifssh.configFilehas not been set, the default is the standard SSH configuration file~/.ssh/config. If you specify--ssh-config-filewith an empty value, the default file specified byssh.configFileis ignored, and the~/.ssh/configfile is used instead. -
Specify the path to an identity file for the connection to the SSH server. The default if this option is not specified is the standard private key file in the SSH configuration folder (
~/.ssh/id_rsa). -
Options that begin with
--sslspecify whether to connect to the server using SSL and indicate where to find SSL keys and certificates. The mysqlsh SSL options function in the same way as the SSL options for MySQL Server, see Command Options for Encrypted Connections for more information.mysqlsh accepts these SSL options:
--ssl-mode,--ssl-ca,--ssl-capath,--ssl-cert,--ssl-cipher,--ssl-crl,--ssl-crlpath,--ssl-key,--tls-version,--tls-ciphersuites. -
Send SQL statements that you issue in MySQL Shell’s SQL mode to the operating system’s system logging facility (
syslogon Unix, or the Windows Event Log). System logging for SQL statements only takes place when MySQL Shell is started in interactive mode, so either a normal start or a start with the--interactiveoption. It does not take place if the--executeor--fileoptions are used at startup to runmysqlshin batch mode. See Section 13.3, “System Logging for User SQL Statements” for more information. -
Display results in tab separated format in interactive mode. The default for that mode is table format. This option is an alias of the
--result-format=tabbedoption. -
Display results in table format in batch mode. The default for that mode is tab separated format. This option is an alias of the
--result-format=tableoption. -
Create a connection upon startup, specifying the connection options in a URI-like string as described at Connecting to the Server Using URI-Like Strings or Key-Value Pairs.
-
--user=,user_name-uuser_nameThe MySQL user name to use when connecting to the server.
-
Activate verbose output to the console and specify the level of detail. The value is an integer in the range from 0 to 4. 0 displays no messages, which is the default verbosity setting when you do not specify the option. 1 displays error, warning and informational messages (this is the default setting if you specify the option on the command line without a value). 2, 3, and 4 add higher levels of debug messages. See Chapter 13, MySQL Shell Logging and Debug for more information.
-
--version,-VDisplay the version of MySQL Shell and exit.
-
--vertical,-EDisplay results vertically, as when the
\Gterminator is used for an SQL query. This option is an alias of the--result-format=verticaloption.