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

exception發表於2018-12-17

第一種情況

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
第二種情況

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配置屬性)以使用更具體的時區值。

<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
第三種情況

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

相關文章