W3docs

Warning about SSL connection when connecting to MySQL database

If you are getting a warning about an SSL connection when connecting to a MySQL database, it may be because you are using an older version of the MySQL client library that does not support SSL connections by default.

If you are getting a warning about an SSL connection when connecting to a MySQL database, it typically appears with MySQL 8.0+ and newer JDBC drivers. This often happens because the connection parameters do not explicitly specify the SSL mode, or you are using deprecated properties.

To fix this warning, you have a few options:

  1. Upgrade to a newer version of the MySQL JDBC driver (Connector/J 8.0+) that handles SSL configuration more securely by default.
  2. If using the MySQL CLI client, pass the --ssl-mode=REQUIRED flag to enforce an encrypted connection.
  3. For JDBC connections, set the sslMode parameter in the connection URL. For example:
    jdbc:mysql://hostname:port/database?sslMode=REQUIRED
  4. To disable server certificate validation (not recommended for production), set sslMode to DISABLED. For example:
    jdbc:mysql://hostname:port/database?sslMode=DISABLED

Note that useSSL and verifyServerCertificate were deprecated in Connector/J 8.0. If you are maintaining a legacy application that still relies on older drivers, you may need to keep the old parameters or upgrade the driver and update the connection string accordingly. Disabling server certificate validation may compromise connection security in production environments.

I hope this helps! Let me know if you have any questions.