mac mysql修改默认时区为 utc

如果你的时区设置是 +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 set
Time: 0.025s

步骤一:

编辑 /etc/my.cnf 文件

cd /etc
sudo 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 set
Time: 0.025s

你可能感兴趣的:(macosmysql)