With an unencrypted connection between the MySQL client and the server, someone with access to the network could watch all your traffic and look at the data being sent or received, or even change the data while it is in transit between client and server.
When you must move information over a network in a secure fashion, an unencrypted connection is unacceptable. Encryption is the way to make any kind of data unreadable. 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.
The Secure Sockets Layer (SSL) protocol uses encryption algorithms to ensure that data received over a public network can be trusted. It has mechanisms to detect any data change, loss, or replay. SSL also incorporates algorithms that provide identity verification using the X509 standard.
X509 makes it possible to identify someone on the Internet. It is most commonly used in e-commerce applications. 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 show the certificate to another party as proof of identity. A certificate consists of its owner's public key. Any data encrypted with this public key can be decrypted only using the corresponding secret key, which is held by the owner of the certificate.
For more information about SSL, X509, encryption, or public-key cryptography, perform an Internet search for the keywords in which you are interested.
MySQL supports secure (encrypted) connections between clients and
the server using the SSL protocol. MySQL supports TLSv1.0. As of
MySQL 5.6.23, it explicitly disables SSL 2.0 and SSL 3.0 because
they provide weak encryption. To see which protocol version an SSL
connection uses, check the value of the
Ssl_version status variable
using this query:
SHOW SESSION STATUS LIKE 'Ssl_version';+---------------+-------+ | Variable_name | Value | +---------------+-------+ | Ssl_version | TLSv1 | +---------------+-------+
MySQL enables encryption on a per-connection basis, and use of SSL
can be optional or mandatory. You can choose an unencrypted
connection or a secure encrypted SSL connection according to the
requirements of individual applications. For information on how to
require users to use SSL connections, see the discussion of the
REQUIRE clause of the
GRANT statement in
Section 18.104.22.168, “GRANT Syntax”.
Encrypted connections are not used by default. For applications that require the security provided by encrypted connections, the extra computation to encrypt the data is worthwhile.
Replication uses the C API, so secure connections can be used between master and slave servers. See Section 17.3.7, “Setting Up Replication Using SSL”.
MySQL can be compiled using OpenSSL or yaSSL. For a comparison of the two packages, see Section 22.214.171.124, “OpenSSL Versus yaSSL”
Another way to connect securely is from within an SSH connection to the MySQL server host. For an example, see Section 6.3.12, “Connecting to MySQL Remotely from Windows with SSH”.