MySQL如何修改时区

版权声明:Jack魏 版权所有,欢迎转载 [如有雷同,请联系作者!]. https://blog.csdn.net/WeiHao0240/article/details/86575561

当出现以下错误时需要改时区:

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命令行模式修改

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

猜你喜欢

转载自blog.csdn.net/WeiHao0240/article/details/86575561
今日推荐