MySQL8.0版本連接問題(解決驅動時區報錯)

8.0版本把驅動改爲com.mysql.cj.jdbc.Driver後如果還報錯
運行報錯:
The server time zone value '?D1ú±ê×?ê±??' 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 utili
錯誤原因:time zone 時區錯誤
解決方法:
1.在cmd使用root用戶登錄mysql
2.show variables like '%time_zone%';
system_time_zone是值是SYSTEM(美國時間)
SYSTEM爲SQL默認美國時間,而我們中國要比他們遲8小時
3.時區設置爲當前系統時區即可,採用+8:00格式:set global time_zone='+8:00';
4.再次查看show variables like '%time_zone%';
5.如果system_time_zone是值是+8:00,可返回重新運行

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