IDEA连接MySQL失败报错Server returns invalid timezone. Go to 'Advanced' tab and set 'serverTimezon

错误现象:

Server returns invalid timezone. Go to 'Advanced' tab and set 'serverTimezon

原因:

  1. MySQL驱动版(jar)本不匹配
  2. MySQL时区错误,MySQL默认的时区是UTC时区,比北京时间晚8个小时

解决方法:

方法一:下载匹配的MySQL驱动版本(jar)

方法二:更改MySQL数据库的时区

在mysql的命令模式下,输入:

set global time_zone='+8:00';
  1. 打开cmd命令窗口(Win + R),连接数据库:输入 mysql -hlocalhost -uroot -p,回车,输入密码,回车:
    mysql -hlocalhost -uroot -p
  2. 设置时区:输入set global time_zone = '+8:00';  注意不要漏掉后面的分号):
    set global time_zone='+8:00';

方法三:在IDEA连接MySQL时中更改相应设置

发布了705 篇原创文章 · 获赞 666 · 访问量 143万+

猜你喜欢

转载自blog.csdn.net/qq_36761831/article/details/104844451