报错页面

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

UTC代表的是全球标准时间 ,但是我们使用的时间是北京时区也就是东八区,领先UTC八个小时。
因为时区不一致,服务器返回了无效的时区。

IDE连MySQL:Server returns invalid timezone. Go to ‘Advanced‘ tab and set ‘serverTimezone‘ property

临时解决方法

1. 去Advanced中找到serverTimezone,更改为Asia/Shanghai

IDE连MySQL:Server returns invalid timezone. Go to ‘Advanced‘ tab and set ‘serverTimezone‘ property

2. 点击apply,重新Test Connection

IDE连MySQL:Server returns invalid timezone. Go to ‘Advanced‘ tab and set ‘serverTimezone‘ property

注意 :下次链接需要再次修改serverTimezone,所以为临时修改

设置MySQL的时区

1. 进入命令窗口(Win + R),连接数据库 mysql -uroot -p,回车,输入密码
2. 继续输入 show variables like'%time_zone';

IDE连MySQL:Server returns invalid timezone. Go to ‘Advanced‘ tab and set ‘serverTimezone‘ property

3. 设置MySQL的时区,输入set global time_zone = '+8:00'; 回车

IDE连MySQL:Server returns invalid timezone. Go to ‘Advanced‘ tab and set ‘serverTimezone‘ property

4. 重新打开命令窗口,链接数据库,查看此时MySQL的时区

IDE连MySQL:Server returns invalid timezone. Go to ‘Advanced‘ tab and set ‘serverTimezone‘ property

5. 此时再去重新Test Connection,便成功了。

IDE连MySQL:Server returns invalid timezone. Go to ‘Advanced‘ tab and set ‘serverTimezone‘ property

相关文章:

  • 2021-10-05
  • 2022-12-23
  • 2021-08-04
  • 2021-07-11
  • 2021-12-28
猜你喜欢
  • 2021-07-07
  • 2021-11-18
  • 2021-10-12
  • 2021-11-24
  • 2021-12-08
相关资源
相似解决方案