Idea、PyCharm连接MySQL报错: Server returns invalid timezone. Go to 'Advanced' tab and set 'serverTimezone

Idea、PyCharm连接MySQL报错:

Server returns invalid timezone. Go to 'Advanced' tab and set 'serverTimezone' property manually.

 

Idea、PyCharm连接MySQL报错: Server returns invalid timezone. Go to 'Advanced' tab and set 'serverTimezone

 

原因:服务器返回无效时区,转到“高级”选项卡并手动设置“serverTimezone”属性。

(首先,出现该问题的原因是MySQL驱动jar中的默认时区是UTC。

UTC代表的是全球标准时间 ,但是我们使用的时间是北京时区也就是东八区,领先UTC八个小时。

因为时区不一致,所以提示Server returns invalid timezone. Go to 'Advanced' tab and set 'serverTimezone' property manually

服务器返回了无效的时区,去“高级”标签中手工设置“serverTimezon"属性值。

解决方法一:
在mysql的命令行窗口输入以下命令即可:
show variables like '%time_zone%';

set global time_zone = '+8:00';

Idea、PyCharm连接MySQL报错: Server returns invalid timezone. Go to 'Advanced' tab and set 'serverTimezone

 

回到PyCharm再次点击“测试连接”,已经成功了。

Idea、PyCharm连接MySQL报错: Server returns invalid timezone. Go to 'Advanced' tab and set 'serverTimezone

 

 

解决方法二:

Idea、PyCharm连接MySQL报错: Server returns invalid timezone. Go to 'Advanced' tab and set 'serverTimezone

 

 

解决方案三:

在最终url 上 追加 ?serverTimezone=GMT

就可以 例子:jdbc:mysql://localhost:3306/test?serverTimezone=GMT

Idea、PyCharm连接MySQL报错: Server returns invalid timezone. Go to 'Advanced' tab and set 'serverTimezone

每个人遇到的情况不一样,希望对大家有帮助啦。

欢迎关注微信公众号,访问更多精彩:数据之魅

如需转载,请联系授权,谢谢合作。

Idea、PyCharm连接MySQL报错: Server returns invalid timezone. Go to 'Advanced' tab and set 'serverTimezone