使用最新版本MySQL8.0.12報錯記錄

使用最新版本MySQL報錯,MySQL版本8.0.12。

報錯1:

Sun Oct 14 00:45:30 CST 2018 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.
不建議在沒有服務器身份驗證的情況下建立SSL連接。根據MySQL 5.5.45+,5.6.26+和5.7.6+的SSL連接要求,如果未設置連接方式,則默認情況下必須建立SSL連接。對於不使用SSL的現有應用程序,服務器的驗證證書屬性設置爲“false”。您需要通過設置useSSL=false來顯式禁用SSL,或者設置useSSL=true並提供服務器的驗證證書。

解決方法:
1、數據庫URL連接地址添加useSSL=false,適用於測試。
2、數據庫URL連接地址添加useSSL=true,並且提供服務器的驗證證書。

jdbc.url=jdbc:mysql://127.0.0.1:3306/demo?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT&useSSL=false

 

報錯2

2018-10-14 00:45:30,876 ERROR [DruidDataSource.java:616] : init datasource error
java.sql.SQLException: The server time zone value '???ú±ê×??±??' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.
服務器時區值“????±××?±?無法識別或代表一個以上的時區。如果希望利用時區支持,則必須配置服務器或JDBC驅動程序(通過serverTimezone配置屬性)以使用更具體的時區值。

解決方法:
使用的MySQL數據庫版本8.0.12,數據庫連接驅動是8.0.12。
由於數據庫和系統時區差異造成報錯,需要在數據庫URL連接地址後面加上serverTimezone=GMT。
如果需要使用gmt+8時區,需要寫成GMT%2B8,否則會被解析爲空。

<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>8.0.12</version>
</dependency>
jdbc.url=jdbc:mysql://127.0.0.1:3306/demo?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT&useSSL=false

 

報錯3:

Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
不建議使用驅動類'com.mysql.jdbc.Driver'。新的驅動程序類是'com.mysql.cj.jdbc.Driver',驅動程序是通過SPI自動註冊的,通常是不需要手動加載驅動類。

解決方法:
MySQL數據庫8.0.12使用的驅動類爲com.mysql.cj.jdbc.Driver,不要使用舊的驅動類。

jdbc.driverClass=com.mysql.cj.jdbc.Driver

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章