本文内容大多基于官方文档和网上前辈经验总结,经过个人实践加以整理积累,仅供参考。
使用 JDBC 连接 MySQL 数据库报以下警告:
Sun Mar 19 20:51:50 CST 2017 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
从警告信息中可以看出,5.5.45+、5.6.26+ 和 5.7.6+ 版本默认 SSL 连接,除非特别指定不需要 SSL 连接,最好在 JDBC URL 中指明连接方式:
String jdbcUrl = "jdbc:mysql:///test?useSSL=false";