MySQL数据库的时区配置过程:
以5.6.19为例。
root@(none) 01:43:17>show variables like '%time_zone%';
+------------------+--------+
| Variable_name | Value |
+------------------+--------+
| system_time_zone | CST |
| time_zone | SYSTEM |
+------------------+--------+
2 rows in set (0.03 sec)
现在是以系统设置作为依据。
root@(none) 01:46:37>set time_zone="+8:00";
Query OK, 0 rows affected (0.02 sec)
root@(none) 01:46:47>select now();
+---------------------+
| now() |
+---------------------+
| 2016-04-11 13:46:55 |
+---------------------+
1 row in set (0.02 sec)
root@(none) 01:46:55>show variables like '%time_zone%';
+------------------+--------+
| Variable_name | Value |
+------------------+--------+
| system_time_zone | CST |
| time_zone | +08:00 |
+------------------+--------+
2 rows in set (0.09 sec)
也可以通过修改配置文件my.cnf,进行时区的修改。
在文件[mysqld] 之下增加
default-time-zone='+8:00'
以5.6.19为例。
root@(none) 01:43:17>show variables like '%time_zone%';
+------------------+--------+
| Variable_name | Value |
+------------------+--------+
| system_time_zone | CST |
| time_zone | SYSTEM |
+------------------+--------+
2 rows in set (0.03 sec)
现在是以系统设置作为依据。
root@(none) 01:46:37>set time_zone="+8:00";
Query OK, 0 rows affected (0.02 sec)
root@(none) 01:46:47>select now();
+---------------------+
| now() |
+---------------------+
| 2016-04-11 13:46:55 |
+---------------------+
1 row in set (0.02 sec)
root@(none) 01:46:55>show variables like '%time_zone%';
+------------------+--------+
| Variable_name | Value |
+------------------+--------+
| system_time_zone | CST |
| time_zone | +08:00 |
+------------------+--------+
2 rows in set (0.09 sec)
也可以通过修改配置文件my.cnf,进行时区的修改。
在文件[mysqld] 之下增加
default-time-zone='+8:00'
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/26812308/viewspace-2081156/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/26812308/viewspace-2081156/