By default, MySQL transmits data between the client and server without encryption. On public networks or cloud environments, this exposes credentials and query results to interception. SSL/TLS encryption protects data in transit.
Checking SSL Status
Run SHOW VARIABLES LIKE '%ssl%' to see whether SSL is enabled on the server. The have_ssl variable should show YES.
Requiring SSL for a User
You can require SSL for a specific user account using the REQUIRE SSL clause in GRANT or CREATE USER. This forces all connections from that user to be encrypted, even if the server supports unencrypted connections.
Connection with SSL (CLI)
When connecting with the MySQL client, use --ssl-mode=REQUIRED to enforce encryption. In PHP PDO, set PDO::MYSQL_ATTR_SSL_CA to the path of the CA certificate.