MySQL Shell 8.0  /  Getting Started with MySQL Shell  /  MySQL Shell Connections

2.1 MySQL Shell Connections

MySQL Shell can connect to MySQL Server using both the X Protocol and the classic MySQL protocol. You can configure the MySQL server instance that MySQL Shell is connected to in the following ways:

These different ways of connecting to a MySQL server instance all support specifying the connection as:

See Connecting Using a Path for more information.

Important

Regardless of how you choose to connect it is important to understand how passwords are handled by MySQL Shell. By default connections are assumed to require a password. The password is requested at the login prompt, and can be stored using Section 2.2, “Pluggable Password Store”. If the user specified has a password-less account, which is insecure and not recommended, or if socket peer-credential authentication is in use (for example when using Unix socket connections), you must explicitly specify that no password is provided and the password prompt is not required. To do this, use one of the following methods:

  • If you are connecting using a URI type string, place a : after the user in the URI type string but do not specify a password after it.

  • If you are connecting using a data dictionary, provide an empty string using '' after the password key.

  • If you are connecting using individual parameters, either specify the --no-password option, or specify the --password= option with an empty value.

If you do not specify parameters for a connection the following defaults are used:

  • user defaults to the current system user name

  • host defaults to localhost

  • port defaults to the X Plugin port 33060 when using an X Protocol connection, and port 3306 when using a classic MySQL protocol connection

MySQL Shell connections using classic MySQL protocol default to using Unix sockets when the following conditions are met:

  • A TCP port is not specified

  • A host name is not specified or it is equal to localhost

  • A socket is provided with a path to a socket file

  • A classic session is specified

If a host name is specified but it is not localhost, a TCP connection is established. In this case, if a TCP port is not specified the default value of 3306 is used. If the conditions are met for a socket connection but a path to a socket file is not specified then the default socket is used. See Connecting to the MySQL Server.

If the connection to the server is lost, MySQL Shell does not attempt to reconnect automatically. Use the \reconnect command to make MySQL Shell try several reconnection attempts for the current global session with the previously supplied parameters.