On Unix, MySQL Shell connections 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
-Soption is specified, with or without a path to a socket file.
If you specify
--socket with no
value and no equal sign, or
-S without a value,
the default Unix socket file for the protocol is used. If you
specify a path to an alternative Unix socket file, that socket
file is used.
If a host name is specified but it is not
localhost, a TCP connection is established
instead. In this case, if a TCP port is not specified the
default value of 3306 is used.
On Windows, for MySQL Shell connections using classic MySQL protocol, if you specify the host name as a period (.), MySQL Shell connects using a named pipe.
If you are connecting using a URI-like connection string, specify
If you are connecting using key-value pairs, specify
If you are connecting using individual parameters, specify
By default, the pipe name
MySQL is used. You
can specify an alternative named pipe using the
--socket option or as part of the URI-like
In URI-like strings, the path to a Unix socket file or Windows
named pipe must be encoded, using either percent encoding or by
surrounding the path with parentheses. Parentheses eliminate the
need to percent encode characters such as the
/ directory separator character. If the path
to a Unix socket file is included in a URI-like string as part
of the query string, the leading slash must be percent encoded,
but if it replaces the host name, the leading slash must not be
percent encoded, as shown in the following examples:
mysql-js> \connect user@localhost?socket=%2Ftmp%2Fmysql.sock mysql-js> \connect user@localhost?socket=(/tmp/mysql.sock) mysql-js> \connect user@/tmp%2Fmysql.sock mysql-js> \connect user@(/tmp/mysql.sock)
On Windows only, the named pipe must be prepended with the
\\.\ as well as being either
encoded using percent encoding or surrounded with parentheses,
as shown in the following examples:
On Windows, if one or more MySQL Shell sessions are connected to a MySQL Server instance using a named pipe and you need to shut down the server, you must first close the MySQL Shell sessions. Sessions that are still connected in this way can cause the server to hang during the shutdown procedure. If this does happen, exit MySQL Shell and the server will continue with the shutdown procedure.
For more information on connecting with Unix socket files and Windows named pipes, see Connecting to the MySQL Server Using Command Options and Connecting to the Server Using URI-Like Strings or Key-Value Pairs.