首页 > 数据库技术 > 详细

Mysql错误:The server time zone value is unrecognized or represents more than one time zone

时间:2017-04-05 18:19:09      阅读:2018      评论:0      收藏:0      [点我收藏+]

编程访问Mysql数据库时,报出时区错误如下:

The server time zone value ‘й‘ is unrecognized or represents more than one time zone

通常有以下两种解决方法:

第一,在数据库连接语句后添加?serverTimezone=UTC,即默认0时区,但是要注意,该语句需要跟在数据库连接语句的第一个位置,否则会报错,例如:

jdbc.url=jdbc:mysql://localhost:3306/testdatabase?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8

但是这会存在一个问题,在向数据库插入时间字段时,时间会比当前时间早8小时,即当前系统时间减8小时。

第二,修改Mysql的时区为东8区,执行如下命令即可:

set global time_zone=‘+8:00‘


Mysql错误:The server time zone value is unrecognized or represents more than one time zone

原文:http://jincheng.blog.51cto.com/4625177/1913062

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!