Encryption in transit forces client-server traffic to travel through SSL/TLS, protecting credentials and query data from network snooping.
Plain-text MySQL sessions expose logins, card numbers, and order details to anyone on the wire. Enabling SSL/TLS closes that gap, meeting PCI-DSS and GDPR rules without rewriting queries.
Add the CA, server certificate, and private key paths to my.cnf (or my.ini) under [mysqld]
. Restart the server so it advertises TLS during the handshake.
Use CREATE USER
or ALTER USER
with the REQUIRE
clause. This flags the account so any non-encrypted login fails immediately.
The REQUIRE
clause supports SSL
, X509
, issuer, subject, and cipher checks. Combine them to lock clients to specific certificates or algorithms.
Run SHOW STATUS LIKE 'Ssl_cipher'
. A non-empty value proves the session is using TLS. Scripts can assert this after connecting.
\# my.cnf[mysqld]ssl-ca = /etc/mysql/certs/ca.pemssl-cert = /etc/mysql/certs/server-cert.pemssl-key = /etc/mysql/certs/server-key.pem
CREATE USER 'app_user'@'%' IDENTIFIED BY 'S3cure!' REQUIRE SSL;
mysql --ssl-mode=REQUIRED --ssl-ca=ca.pem -u app_user -p
SELECT c.name, SUM(oi.quantity) AS itemsFROM Customers cJOIN Orders o ON o.customer_id = c.idJOIN OrderItems oi ON oi.order_id = o.idWHERE o.order_date >= CURDATE() - INTERVAL 30 DAYGROUP BY c.name;
Rotate certificates annually, store keys outside the repo, enforce ssl-mode=REQUIRED
on all clients, and monitor performance_schema.session_status
for Ssl*
metrics.
Do not leave ssl-mode=DISABLED
in connection strings after testing. Avoid self-signed certificates in production—use a trusted internal CA.
Over LAN links the overhead is usually <1 ms per query. Modern CPUs handle TLS with negligible impact.
Yes, but it is discouraged. Use ALTER USER ... REQUIRE SSL
to migrate each account until all traffic is protected.
MySQL 8.0.16+ compiled against OpenSSL 1.1.1 or higher negotiates TLS 1.3 automatically.