环境介绍:
OS版本:RHEL5.5
MySQL版本:5.5.40
参考链接:http://dev.mysql.com/doc/refman/5.5/en/time-zone-leap-seconds.html
有一个需求:一个考勤系统,多个AP分布在全球,时间必须以+8时区来计算,那必须修改MySQL服务器时间来决定!
查看mysql server当前时区
mysql> show variables like ‘%time_zone%‘;
+------------------+--------+
| Variable_name | Value |
+------------------+--------+
| system_time_zone | CST |
| time_zone | SYSTEM |
+------------------+--------+
2 rows in set (0.00 sec)
修改办法:
方法1:修改my.cnf
[mysqld]
default-time-zone=‘+8:00‘
保存,退出
重启mysql 服务器
方法2:修改参数
mysql> set time_zone = ‘+8:00‘;
验证:
mysql> show variables like ‘%time_zone%‘;
+------------------+--------+
| Variable_name | Value |
+------------------+--------+
| system_time_zone | CST |
| time_zone | +08:00 |
+------------------+--------+
2 rows in set (0.00 sec)
mysql> select now();
+---------------------+
| now() |
+---------------------+
| 2011-18-21 18:39:07 |
+---------------------+
1 row in set (0.00 sec)