- 6.3.1 Configuring MySQL to Use Encrypted Connections
- 6.3.2 Command Options for Encrypted Connections
- 6.3.3 Creating SSL and RSA Certificates and Keys
- 6.3.4 SSL Library-Dependent Capabilities
- 6.3.5 Building MySQL with Support for Encrypted Connections
- 6.3.6 Encrypted Connection Protocols and Ciphers
- 6.3.7 Connecting to MySQL Remotely from Windows with SSH
With an unencrypted connection between the MySQL client and the server, someone with access to the network could watch all your traffic and inspect the data being sent or received between client and server.
When you must move information over a network in a secure fashion, an unencrypted connection is unacceptable. To make any kind of data unreadable, use encryption. Encryption algorithms must include security elements to resist many kinds of known attacks such as changing the order of encrypted messages or replaying data twice.
MySQL supports encrypted connections between clients and the server using the TLS (Transport Layer Security) protocol. TLS is sometimes referred to as SSL (Secure Sockets Layer) but MySQL does not actually use the SSL protocol for encrypted connections because its encryption is weak (see Section 6.3.6, “Encrypted Connection Protocols and Ciphers”).
TLS uses encryption algorithms to ensure that data received over a public network can be trusted. It has mechanisms to detect data change, loss, or replay. TLS also incorporates algorithms that provide identity verification using the X.509 standard.
X.509 makes it possible to identify someone on the Internet. In basic terms, there should be some entity called a “Certificate Authority” (or CA) that assigns electronic certificates to anyone who needs them. Certificates rely on asymmetric encryption algorithms that have two encryption keys (a public key and a secret key). A certificate owner can present the certificate to another party as proof of identity. A certificate consists of its owner's public key. Any data encrypted using this public key can be decrypted only using the corresponding secret key, which is held by the owner of the certificate.
MySQL can be compiled for encrypted-connection support using OpenSSL or wolfSSL. For a comparison of the packages, see Section 6.3.4, “SSL Library-Dependent Capabilities” For information about the encryption protocols and ciphers each package supports, see Section 6.3.6, “Encrypted Connection Protocols and Ciphers”.
By default, MySQL programs attempt to connect using encryption if the server supports encrypted connections, falling back to an unencrypted connection if an encrypted connection cannot be established. For information about options that affect use of encrypted connections, see Section 6.3.1, “Configuring MySQL to Use Encrypted Connections” and Section 6.3.2, “Command Options for Encrypted Connections”.
MySQL performs encryption on a per-connection basis, and use of
encryption for a given user can be optional or mandatory. This
enables you to choose an encrypted or unencrypted connection
according to the requirements of individual applications. For
information on how to require users to use encrypted connections,
see the discussion of the
REQUIRE clause of the
CREATE USER statement in
Section 18.104.22.168, “CREATE USER Syntax”. See also the description of the
variable at Section 5.1.8, “Server System Variables”
Encrypted connections can be used between master and slave replication servers. See Section 17.3.9, “Setting Up Replication to Use Encrypted Connections”.
For information about using encrypted connections from the MySQL C API, see Section 28.7.22, “C API Encrypted Connection Support”.
It is also possible to connect using encryption from within an SSH connection to the MySQL server host. For an example, see Section 6.3.7, “Connecting to MySQL Remotely from Windows with SSH”.