使用spring boot整合MySQL時一直報
java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one time zone
報錯信息
系統時區的錯誤
查看mysql時區
show VARIABLES like "%time_zone%"
解決方法:
1.在原來的參數“url”后面,拼上這個字符串:?serverTimezone=GMT%2B8,
如:
jdbc:mysql://localhost:3306/test?serverTimezone=GMT%2B8
東八區的表示:
GMT%2B8,
即GMT+8,北京時間東八區
Asia/Shangha,上海時間
2.設置mysql的時區
MySQL默認的時區是UTC時區
(1)永久的修改:修改mysql的配置文件,添加:default-time-zone='+08:00',重啟mysql生效
(2)臨時的修改:執行mysql命令 set global time_zone='+08:00',立即生效,重啟mysql后失效
