如果你的时区设置是 +08:00 阐明是北京工夫,然而咱们线上的服务器都是 UTC 工夫的,这种差别会带来一些非预期的后果。让咱们对立设为 UTC 时区吧!

MySQL root@(none):(none)> show variables like'%time_zone';+------------------+--------+| Variable_name    | Value  |+------------------+--------+| system_time_zone | CST    || time_zone        | +08:00 |+------------------+--------+2 rows in setTime: 0.025s

步骤一:

编辑 /etc/my.cnf 文件

cd /etcsudo vim my.cnf

步骤二:

输出以下内容

[mysqld]default-time-zone='+08:00'  

保留退出

步骤三:

重启 mysql server

步骤四:

登录 mysql server,如果是上面这样就是失效了

MySQL root@(none):(none)> show variables like'%time_zone';+------------------+--------+| Variable_name    | Value  |+------------------+--------+| system_time_zone | CST    || time_zone        | +00:00 |+------------------+--------+2 rows in setTime: 0.025s