MySQL报错“The server time zone value '�й���׼ʱ��' is unrecognized”

“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 specific time zone value if you want to utilize time zone support.”

 

方法1
修改数据库时区。在cmd命令中进入MySQL输入如下命令即可。
set global time_zone = '+8:00';  ##修改mysql全局时区为北京时间,即我们所在的东8区
set time_zone = '+8:00';  ##修改当前会话时区
flush privileges;

缺点:此方法可以临时解决问题,但是一旦关机或重启mysql服务后下一次又需要重新去设置。


方法2
在MySQL的配置文件my.ini中加入
default-time_zone = '+8:00'

 

方法3

在连接字符串后面加上“?serverTimezone=UTC”

例如:

jdbc:mysql://localhost:3306/database?serverTimezone=UTC"

 

posted @ 2021-01-26 16:35  Clotho_Lee  阅读(270)  评论(0)    收藏  举报