JDBC连接mysql错误处理

异常错误:Wed Jan 09 14:15:30 CST 2019 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.

解决办法 
在mysql连接字符串url中加入ssl=true或者false即可,如:

jdbc:mysql://X203:3306/testdb?useUnicode=true&characterEncoding=utf8&useSSL=false

备注 
启用SSL加密连接后,性能必然会有下降。 
由于SSL开销较大的环节在建立连接,所以短链接的开销可能会更大,因此推荐使用长连接或者连接池的方式来减小SSL所带来的额外开销,不过好在MySQL的应用习惯大部分也是长连接的方式。

总结 
1.MySQL 5.7配置SSL要比5.6来的简单的多 
2.MySQL 5.7客户端默认开启SSL加密连接 
3.通常来说,开启SSL加密连接后,性能最大的开销在25%左右
 

你可能感兴趣的:(Mysql数据库)