Caused by: java.sql.SQLException: The server time zone value ‘EDT‘ 的解决方法

问题描述

项目启动出现异常信息:

Caused by: java.sql.SQLException: The server time zone value ‘EDT’ is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.

由异常信息可以看出是数据库时区问题

登录数据库,查找时区:

mysql -u root -p
show variables like “%time_zone%”;

显示如下:

mysql默认使用了系统时区,查看当前的系统时区,可以发现当前的Time zone为EDT时区

解决方法

修改mysql全局时区为北京时间,即我们所在的东8区
依次执行命令

set global time_zone = '+8:00';
set time_zone = '+8:00'; 
flush privileges';

永久生效,可以在配置文件中添加配置

[mysqld] 
default-time-zone='+08:00'
posted on 2022-06-09 23:18  猫的树kireCat  阅读(150)  评论(0编辑  收藏  举报