MySQL supports SSL/TLS encryption to secure communication between clients and servers. Follow these steps to enable SSL in your MySQL setup:

  1. Generate SSL Certificates
    Use tools like openssl 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
    
    mysql_ssl_configuration
  2. Configure MySQL Server
    Edit the MySQL configuration file (my.cnf or my.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.

  3. Restart MySQL Service
    Apply changes by restarting the MySQL service:

    sudo systemctl restart mysql
    
  4. Verify SSL Status
    Connect to MySQL and check:

    SHOW VARIABLES LIKE 'ssl%';
    

    🔍 If SSL is enabled, you'll see SSL_PROTOCOL and SSL_CIPHER values.

For advanced configurations, refer to our SSL Best Practices Guide.
🔒 Always use strong encryption protocols and keep your certificates updated.