环境

mysql8
idea2019

错误信息

IDEA连接mysql,地址,用户名,密码,数据库名,全都配置正确,点测试连接,报错如下
Idea连接mysql 报错Server returns invalid timezone. Go to 'Advanced' tab and set 'serverTimezone' property manually.

解决操作

  1. 设置mysql的时区
  2. mysql驱动的版本

进入命令窗口(Win + R),连接数据库 mysql -hlocalhost -uroot -p,回车,输入密码,回车
继续输入 show variables like'%time_zone'; (注意不要漏掉后面的分号),回车,如下图:
Idea连接mysql 报错Server returns invalid timezone. Go to 'Advanced' tab and set 'serverTimezone' property manually.
显示 SYSTEM 就是没有设置时区

输入set global time_zone = '+8:00'; 注意不要漏掉后面的分号),回车,如下图:
Idea连接mysql 报错Server returns invalid timezone. Go to 'Advanced' tab and set 'serverTimezone' property manually.

重新连接下数据库,连接成功
Idea连接mysql 报错Server returns invalid timezone. Go to 'Advanced' tab and set 'serverTimezone' property manually.

Idea连接mysql 报错Server returns invalid timezone. Go to 'Advanced' tab and set 'serverTimezone' property manually.

如果此时还是测试连接失败,那就是需要修改mysql驱动版本。把Driver·改成·MySQL for 5.1就可以了
Idea连接mysql 报错Server returns invalid timezone. Go to 'Advanced' tab and set 'serverTimezone' property manually.

使用set global time_zone = '+8:00';在mysql重启后失效,如需永久生效,需要在my.ini增加如下配置

[mysqld]
# 设置默认时区
default-time_zone='+8:00'

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

相关文章: