# mysql报错-20210905
# 背景
- 数据库版本:5.7.35
- 数据库连接配置(报错)
url: jdbc:mysql://${mysql.url}:3307/febs_cloud_base?useUnicode=true&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2b8
1
- 项目启动报错
2021-09-05 12:30:06 ERROR FEBS-Auth main com.zaxxer.hikari.pool.HikariPool base - Exception during pool initialization.
com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
1
2
3
4
2
3
4
- 数据库日志内容内容
2021-09-05T04:15:01.925438Z 23 [Note] Bad handshake
1
# 原因
原因就是连接串错误地设置了 useSSL=true。
在 5.7.27 版本由于实际上不支持 SSL 连接,所以设置 useSSL 居然不会报错,而会降级使用非 SSL 连接;而在 5.7.28 版本,实际上支持了 SSL 连接,所以根据 jdbc 配置 useSSL=true,连接会真的采用 SSL,但应用服务器并没有为服务器证书验证提供 truststore 文件,所以报错了。
# 解决方法
修改 jdbc 连接串,连接串使用了 useSSL=true,改为 useSSL=FALSE