当出现以下错误时需要改时区:
java.sql.SQLException:
The server time zone value 'Öйú±ê׼ʱ¼ä'
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命令行模式修改
mysql -h 192.168.120.244 -u root -p #登录
show variables like "%time_zone%"; #查看当前时区
set global time_zone = '+8:00'; #修改MySQL全局时区为北京时间
方法二:修改my.cnf配置文件
# 找到配置文件 vim /etc/my.cnf
default-time_zone = '+8:00'
# 重启MySQL服务 /etc/init.d/mysqld restart