4
mac mysql修改默认时区为 utc
source link: https://segmentfault.com/a/1190000040893230
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
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
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK