MYSQL:WARN: Establishing SSL connection without server's identity verification is not recommended.

 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

是Mysql數據庫的SSL鏈接問題,提示警告不建議使用沒有帶服務器身份驗證的SSL鏈接,是在MYSQL5.5.45+, 5.6.26+ and 5.7.6+版本中才有的這個問題。解決辦法在警告中已經說明了:sql

1.在數據庫鏈接的url中添加useSSL=false;
2.url中添加useSSL=true,而且提供服務器的驗證證書。
若是隻是作一個測試的話,不必搞證書那麼麻煩啦,在鏈接後添加一個useSSL=false便可,例如:數據庫

jdbc:mysql://localhost:3306/test?useSSL=false
在使用Java進行JDBC鏈接的時候,能夠在Properties對象中設置useSSL的值爲false,可是和寫在連接中是同樣的。好比
 服務器

Properties properties = new Properties();
properties.setProperty("user", "root");
properties.setProperty("password", "milos23);
properties.setProperty("useSSL", "false");
properties.setProperty("autoReconnect", "true");
try (Connection conn = DriverManager.getConnection(connectionUrl, properties)) {
	...
} catch (SQLException e) {
	...
}
相關文章
相關標籤/搜索