MySQL Shell 8.0  /  MySQL Shell Command Reference  /  mysqlsh — The MySQL Shell

A.1 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 MySQL Shell 8.0 (part of MySQL 8.0). 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, see InnoDB Cluster.

mysqlsh supports the following command-line options.

mysqlsh Options Command-line options available for mysqlsh.

  • --help

    Display a help message and exit.

  • --auth-method=method

    Authentication method to use for the account. Depends on the authentication plugin used for the account's password. MySQL Shell currently supports the following methods:

  • --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 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, -f 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.

  • --get-server-public-key

    MySQL Shell equivalent of --get-server-public-key.

    Important

    Only supported with classic MySQL protocol connections.

    See Caching SHA-2 Pluggable Authentication.

  • --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 Chapter 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-password

    When connecting to the server, if the user has a password-less account, which is insecure and not recommended, or if socket peer-credential authentication is in use (for Unix socket connections), you must use --no-password to explicitly specify that no password is provided and the password prompt is not required.

  • --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. With a value provided, --password is an alias for --dbpassword. With an empty value provided, --password= has the same effect as --no-password, which specifies that no password is provided and the password prompt is not required.

  • --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.

  • --server-public-key-path=file_name

    MySQL Shell equivalent of --server-public-key-path.

    Important

    Only supported with classic MySQL protocol connections.

    See caching_sha2_password plugin Caching SHA-2 Pluggable Authentication.

  • --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 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.

  • --tabbed

    Display output in tab separated format in Interactive mode. The default is table format.

  • --table

    Display output in table format in Batch mode. The default is tab separated format.

  • --uri=str

    Create a connection upon startup, specifying the connection options in a URI string format, see Connecting Using a Path.

  • --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.


PREV   HOME   UP