編碼的世界 / 優質文選 / 歷史

一、MySQL數據庫設置默認時區


2021年10月18日
-   

打開CMD
將工作目錄切換到MySQL的bin下
cd F:mysql-5.7.21-winx64in
mysql -u root -p
輸入密碼即可登陸MySQL
select now(); 查看mysql系統時間。和當前時間做對比
set global time_zone = '+8:00'; 設置時區更改為東八區
flush privileges; 刷新權限

如果不設置默認時區,會出現以下異常:
Caused by: 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.

熱門文章