Documentation Home
MySQL 8.0 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 37.7Mb
PDF (A4) - 37.7Mb
PDF (RPM) - 33.8Mb
HTML Download (TGZ) - 8.4Mb
HTML Download (Zip) - 8.4Mb
HTML Download (RPM) - 7.3Mb
Man Pages (TGZ) - 130.0Kb
Man Pages (Zip) - 185.6Kb
Info (Gzip) - 3.3Mb
Info (Zip) - 3.3Mb


MySQL 8.0 Reference Manual  /  ...  /  mysqlsh — The MySQL Shell

Pre-General Availability Draft: 2018-02-22

4.5.7 mysqlsh — The MySQL Shell

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 Chapter 19, MySQL Shell User Guide. 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 Chapter 20, Using MySQL as a Document Store. MySQL Shell includes the AdminAPI that enables you to work with InnoDB cluster, see Chapter 22, InnoDB Cluster.

mysqlsh supports the following command-line options.

Table 4.14 mysqlsh Options

FormatDescriptionIntroduced
--auth-methodAuthentication method to use 
--classicDeprecated in version 8.0.3. Create a ClassicSession 
--clusterConnect to an InnoDB cluster8.0.4
--databaseThe schema to use (alias for --schema) 
--dbaEnable X Protocol on connection with server 
--dbpasswordPassword to use when connecting to server 
--dbuserMySQL user name to use when connecting to server 
--executeExecute the command and quit 
--fileFile to process in Batch mode 
--forceContinue in SQL and Batch modes even if errors occur 
--helpDisplay help message and exit 
--hostConnect to MySQL server on given host 
--interactiveEmulate Interactive mode in Batch mode 
--javascript, --jsStart in JavaScript mode 
--jsonPrint output in JSON format 
--log-levelSpecify logging level 
-maDetect session protocol automatically8.0.3
--mysql, -mcCreate a session using MySQL protocol8.0.3
--mysqlx, -mxCreate a session using X Protocol8.0.3
--name-cacheEnable automatic loading of table names based on the active default schema8.0.4
--no-name-cacheDisable autocompletion.8.0.4
--no-wizard, --nwDisable the connection wizard 
--nodeDeprecated in version 8.0.3. Create a NodeSession 
--passwordPassword to use when connecting to server (alias for --dbpassword) 
--passwords-from-stdinRead the password from stdin 
--portTCP/IP port number for connection 
--py, --pythonStart in Python mode 
--recreate-schemaDrop and recreate schema 
--redirect-primaryEnsure connection to an InnoDB cluster's primary8.0.4
--redirect-secondaryEnsure connection to an InnoDB cluster's secondary 
--schemaThe schema to use 
--show-warningsShow warnings after each statement if there are any (in SQL mode) 
--socketFor connections to localhost, the Unix socket file to use, or pipe name on Windows (ClassicSessions only) 
--sqlStart in SQL mode 
--sqlcStart in SQL mode using a ClassicSession 
--sqlnDeprecated in version 8.0.3. Start in SQL mode using a NodeSession 
--sqlxStart in SQL mode using an X Protocol connection8.0.3
--sslEnable an SSL connection. Deprecated in version 1.0.10; use --ssl-mode instead. 
--ssl-caFile that contains list of trusted SSL Certificate Authorities 
--ssl-capathDirectory that contains trusted SSL Certificate Authority certificate files 
--ssl-certFile that contains X509 certificate 
--ssl-cipherName of the SSL cipher to use 
--ssl-crlFile that contains certificate revocation lists 
--ssl-crlpathDirectory that contains certificate revocation list files 
--ssl-keyFile that contains X509 key 
--ssl-modeSecurity state of connection to server 
--tableDisplay output in tabular format 
--tls-versionProtocols permitted for encrypted connections 
--uriSession information in URI format 
--userMySQL user name to use when connecting to server (alias for --dbuser) 
--versionDisplay version information and exit 
--verticalDisplay all SQL results vertically 

  • --help

    Display a help message and exit.

  • --auth-method=method

    Authentication method to use.

  • --classic

    Deprecated in version 8.0.3.

    Creates a Classic session, to connect using MySQL Protocol.

  • --cluster

    Ensures that the target server is part of an InnoDB cluster and if so, sets the cluster global variable to the cluster object.

  • --database=name

    The default schema to use. This is an alias for --schema.

  • --dba=enableXProtocol

    Enable X Protocol on connection with server. Requires Classic session.

  • --dbpassword[=password], -p[password]

    The password to use when connecting to the server. If you use the short option form (-p), you cannot have a space between the option and the password. If you omit the password value following the --dbpassword or -p option on the command line, you are prompted for one.

    Specifying a password on the command line should be considered insecure. See Section 6.1.2.1, “End-User Guidelines for Password Security”. You can use an option file to avoid giving the password on the command line.

  • --dbuser=user_name, -u user_name

    The MySQL user name to use when connecting to the server.

  • --execute=command, -e command

    Execute the command using the currently active language and quit.

  • --file=file_name

    Specify file to process in Batch mode.

  • --force

    Continue processing in SQL and Batch modes even if errors occur.

  • --host=host_name, -h host_name

    Connect to the MySQL server on the given host.

  • --interactive[=full]

    Emulate Interactive mode in Batch mode.

  • --js

    Start in JavaScript mode.

  • --json[={pretty|raw}]

    Print output in JSON format. With an option value of pretty, output is pretty-printed. With no option value or a value of raw, output is in raw JSON format.

  • --log-level=N

    Specify the logging level. The value can be either an integer in the range from 1 to 8, or one of none, internal, error, warning, info, debug, debug2, or debug3. See Section 19.6, “MySQL Shell Application Log”.

  • -ma

    Detects the session type automatically.

  • --mysql

    Sets the session created at start up to create the connection using MySQL protocol.

  • --mysqlx

    Sets the session created at start up to create the connection using X Protocol.

  • --node

    Deprecated in version 8.0.3.

    Creates a Node session connected using X Protocol to a single server.

  • --name-cache

    Enable automatic loading of table names based on the active default schema.

  • --no-name-cache

    Disable loading of table names for autocompletion based on the active default schema and the DevAPI db object. Use \rehash to reload the name information manually.

  • --no-wizard

    Disables the connection wizard which provides help when creating connections.

  • --passwords-from-stdin

    Read the password from stdin.

  • --password[=password]

    The password to use when connecting to the server. This is an alias for --dbpassword.

  • --port=port_num, -P port_num

    The TCP/IP port number to use for the connection. The default is port 33060.

  • --py

    Start in Python mode.

  • --recreate-schema

    Drop and recreate schema.

  • --redirect-primary

    Ensures that the target server is part of an InnoDB cluster and if it is not a primary, finds the cluster's primary and connects to it. MySQL Shell exits with an error if any of the following is true when using this option:

    • Group Replication is not active

    • InnoDB cluster metadata does not exist

    • There is no quorum

  • --redirect-secondary

    Ensures that the target server is part of an InnoDB cluster 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:

    • 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 in the cluster, for example because there is just one server instance

  • --schema=name, -D name

    The default schema to use.

  • --show-warnings

    Cause warnings to be shown after each statement if there are any.

  • --socket=path, -S path

    For connections to localhost, the Unix socket file to use, or, on Windows, the name of the named pipe to use. This option applies to Classic sessions only.

  • --sql

    Start in SQL mode.

  • --sqlc

    Start in SQL mode using a ClassicSession.

  • --sqln

    Deprecated in version 8.0.3.

    Start in SQL mode using a NodeSession.

  • --sqlx

    Start in SQL mode and create connection using X Protocol.

  • --ssl*

    Options that begin with --ssl specify 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 Section 6.4.2, “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.

  • --table

    Display output in table format in Batch mode.

  • --uri=str

    Create a connection upon startup, specifying the connection options in a URI string format, see Section 19.2.1.1, “Connecting using a URI String”.

  • --user=user_name

    The MySQL user name to use when connecting to the server. This is an alias for --dbuser.

  • --version, -V

    Display version information and exit.

  • --vertical, -E

    Display results of SQL queries vertically.


User Comments
Sign Up Login You must be logged in to post a comment.