6.2.3 Command Options for Connecting to the Server (original) (raw)

6.2.3 Command Options for Connecting to the Server

This section describes options supported by most MySQL client programs that control how client programs establish connections to the server, whether connections are encrypted, and whether connections are compressed. These options can be given on the command line or in an option file.

Command Options for Connection Establishment

This section describes options that control how client programs establish connections to the server. For additional information and examples showing how to use them, seeSection 6.2.4, “Connecting to the MySQL Server Using Command Options”.

Table 6.4 Connection-Establishment Option Summary

Option Name Description Introduced
--default-auth Authentication plugin to use
--host Host on which MySQL server is located
--password Password to use when connecting to server
--password1 First multifactor authentication password to use when connecting to server 8.0.27
--password2 Second multifactor authentication password to use when connecting to server 8.0.27
--password3 Third multifactor authentication password to use when connecting to server 8.0.27
--pipe Connect to server using named pipe (Windows only)
--plugin-dir Directory where plugins are installed
--port TCP/IP port number for connection
--protocol Transport protocol to use
--shared-memory-base-name Shared-memory name for shared-memory connections (Windows only)
--socket Unix socket file or Windows named pipe to use
--user MySQL user name to use when connecting to server
mysql --host=localhost  

To force TCP/IP transport to be used instead, specify a--protocol option:

mysql --host=localhost --protocol=TCP  

The following table shows the permissible--protocol option values and indicates the applicable platforms for each value. The values are not case-sensitive.

--protocol Value Transport Protocol Used Applicable Platforms
TCP TCP/IP transport to local or remote server All
SOCKET Unix socket-file transport to local server Unix and Unix-like systems
PIPE Named-pipe transport to local server Windows
MEMORY Shared-memory transport to local server Windows
See also Section 6.2.7, “Connection Transport Protocols”

Command Options for Encrypted Connections

This section describes options for client programs that specify whether to use encrypted connections to the server, the names of certificate and key files, and other parameters related to encrypted-connection support. For examples of suggested use and how to check whether a connection is encrypted, seeSection 8.3.1, “Configuring MySQL to Use Encrypted Connections”.

For information about using encrypted connections from the MySQL C API, see Support for Encrypted Connections.

--ssl-cipher=AES128-SHA  
--ssl-cipher=DHE-RSA-AES128-GCM-SHA256:AES128-SHA  

OpenSSL supports the syntax for specifying ciphers described in the OpenSSL documentation athttps://www.openssl.org/docs/manmaster/man1/ciphers.html.
For information about which encryption ciphers MySQL supports, seeSection 8.3.2, “Encrypted Connection TLS Protocols and Ciphers”.
To specify the encryption ciphers for the server, set thessl_cipher system variable.

mysql --tls-ciphersuites="suite1:suite2:suite3"  

The ciphersuites that can be named for this option depend on the SSL library used to compile MySQL. If this option is not set, the client permits the default set of ciphersuites. If the option is set to the empty string, no ciphersuites are enabled and encrypted connections cannot be established. For more information, seeSection 8.3.2, “Encrypted Connection TLS Protocols and Ciphers”.
This option was added in MySQL 8.0.16.
To specify which ciphersuites the server permits, set thetls_ciphersuites system variable.

mysql --tls-version="TLSv1.2,TLSv1.3"  

The protocols that can be named for this option depend on the SSL library used to compile MySQL, and on the MySQL Server release.
Important

--tls-version="TLSv1,TLSv1.1,TLSv1.2,TLSv1.3"  
--tls-version="TLSv1.1,TLSv1.2,TLSv1.3"  
--tls-version="TLSv1.2,TLSv1.3"  
--tls-version="TLSv1.3"  
From MySQL 8.0.28, only the last two values are suitable.  

These values do have holes and should not be used:

--tls-version="TLSv1,TLSv1.2"  
--tls-version="TLSv1.1,TLSv1.3"  

For details, seeSection 8.3.2, “Encrypted Connection TLS Protocols and Ciphers”.
To specify which TLS protocols the server permits, set thetls_version system variable.

Command Options for Connection Compression

This section describes options that enable client programs to control use of compression for connections to the server. For additional information and examples showing how to use them, seeSection 6.2.8, “Connection Compression Control”.

Table 6.6 Connection-Compression Option Summary

Option Name Description Introduced Deprecated
--compress Compress all information sent between client and server 8.0.18
--compression-algorithms Permitted compression algorithms for connections to server 8.0.18
--zstd-compression-level Compression level for connections to server that use zstd compression 8.0.18