IDEA连接mysql又报错!Server returns invalid timezone. Go to 'Advanced' tab and set 'serverTimezone' prope

标题问题:

Server returns invalid timezone. Go to ‘Advanced’ tab and set ‘serverTimezone’ prope

翻译过来就是:服务器返回无效时区。进入“高级”选项卡,手动设置“serverTimezone”属性。
IDEA连接mysql又报错!Server returns invalid timezone. Go to 'Advanced' tab and set 'serverTimezone' prope

解决方案

1.输入cmd命令窗口,连接数据库 mysql -hlocalhost -uroot -p,回车,输入密码,回车,如图:
IDEA连接mysql又报错!Server returns invalid timezone. Go to 'Advanced' tab and set 'serverTimezone' prope
2,继续输入 show variables like’%time_zone’; (注意不要漏掉后面的分号),回车,如图:
IDEA连接mysql又报错!Server returns invalid timezone. Go to 'Advanced' tab and set 'serverTimezone' prope
显示 SYSTEM 就是没有设置时区啦。

3,现在我们来设置时区。

输入set global time_zone = ‘+8:00’; 注意不要漏掉后面的分号),回车,如图:
IDEA连接mysql又报错!Server returns invalid timezone. Go to 'Advanced' tab and set 'serverTimezone' prope
这便是设置成功啦!

这时你重新连接下数据库,也许能连接成功!如果没有,就继续往下走!

第二,同步mysql驱动。

我本机安装的mysql版本是5.7的,那么IDEA要连接mysql也应该匹配下驱动版本。把Driver改成MySQL for 5.1就可以了
IDEA连接mysql又报错!Server returns invalid timezone. Go to 'Advanced' tab and set 'serverTimezone' prope
在点击Test Connection测试下,成功啦!
IDEA连接mysql又报错!Server returns invalid timezone. Go to 'Advanced' tab and set 'serverTimezone' prope
【补充】

如果,你选的是MySQL,

数据库又是其他版本的,也没关系。

在驱动列表里找到 MySQL ,右边Driver files 里,选择一下你需要的版本,保存就可以了
IDEA连接mysql又报错!Server returns invalid timezone. Go to 'Advanced' tab and set 'serverTimezone' prope