mysql異常之: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one time zone


連接數據庫時顯示:

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.

這是由於時區問題導致的, 只需要更改MySQL的時區即可:

重啟mysql, 再次輸入: show variables like '%time_zone%';

如果還是顯示time_zone    |     SYSTEM

可能是由於還沒有更新緩存導致的, 再次輸入: set time_zone='+8:00';

set global time_zone = ‘+8:00‘; ##修改mysql全局時區為北京時間,即我們所在的東8區
set time_zone = ‘+8:00‘; ##修改當前會話時區
flush privileges; #立即生效

  

 如果顯示Query Ok, 0 rows affected, 那么很可能是已經更新時區成功了

如果以上方法還不可以解決問題, 那么嘗試在代碼中做調整

jdbc:mysql://127.0.0.1:3306/onestep?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&useSSL=false&serverTimezone=GMT%2B8

重啟服務和應用即可


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM