1. 程式人生 > >The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one time zone問題解決

The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one time zone問題解決

今天在學習Mybatis時使用JDBC連線資料庫時出了一些問題:

一、首先是資料庫驅動更變舊版的com.mysql.jdbc.Driver已過時不再適用,提示更變為com.mysql.cj.jdbc.Driver,通過SPI自動註冊,不再需要手動載入驅動類

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.

二、處理完上面的出現如下Mysql資料庫問題

Sat Apr 14 14:18:21 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.(這個不是主要問題)

之後出現如下問題:

Access denied for user 'root'@'localhost' (using password: YES)

接著處理該內容問題:

以管理員執行cmd.exe ,進入到對應Mysql資料庫bin目錄下

進入mysql資料庫,然後輸入use mysql使用該資料庫,再修改password

最好退出mysql,重啟mysql服務,在命令列中執行"mysql -uroot -padmin",問題解決

三、前面兩個都解決後卻又出現了這個問題

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.

原來是時區問題;我們所在的是東八區:可以設定成"+8:00"來表示東八區;

中間的SYSTEM 是我測試的沒用,只要set global time_zone='+8:00';就可以了

最後再測試下,終於可以了,沒有再報錯了。

第一次沒經驗費了大把精力在找資料,下次再碰到這個問題就有經驗了,以防萬一,記錄下來以作參考