MySQL supports SSL/TLS encryption to secure communication between clients and servers. Follow these steps to enable SSL in your MySQL setup:
Generate SSL Certificates
Use tools likeopenssl
to create self-signed certificates or obtain them from a trusted Certificate Authority (CA).
💡 Example command:openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /path/to/private.key -out /path/to/cert.pem
Configure MySQL Server
Edit the MySQL configuration file (my.cnf
ormy.ini
) and add:[mysqld] ssl-ca=/path/to/ca.pem ssl-cert=/path/to/cert.pem ssl-key=/path/to/private.key
⚠️ Ensure file permissions are set correctly for security.
Restart MySQL Service
Apply changes by restarting the MySQL service:sudo systemctl restart mysql
Verify SSL Status
Connect to MySQL and check:SHOW VARIABLES LIKE 'ssl%';
🔍 If SSL is enabled, you'll see
SSL_PROTOCOL
andSSL_CIPHER
values.
For advanced configurations, refer to our SSL Best Practices Guide.
🔒 Always use strong encryption protocols and keep your certificates updated.