在一台服务器上,当我运行:
mysql> select now();
+---------------------+
| now() |
+---------------------+
| 2009-05-30 16:54:29 |
+---------------------+
1 row in set (0.00 sec)
在另一台服务器上:
mysql> select now();
+---------------------+
| now() |
+---------------------+
| 2009-05-30 20:01:43 |
+---------------------+
1 row in set (0.00 sec)
如果使用指定时区会导致错误:
mysql> SET GLOBAL time_zone = "Asia/Bangkok";
ERROR 1298 (HY000): Unknown or incorrect time zone: 'Asia/Bangkok'
你可以试试:
mysql_tzinfo_to_sql tz_file tz_name | mysql -u root -p mysql
然后:
SET GLOBAL time_zone = "Asia/Bangkok";
SET time_zone = "+07:00";
SET @@session.time_zone = "+07:00";
检查一下现在几点了:
SELECT NOW();
裁判:
https://dev.mysql.com/doc/refman/5.7/en/time-zone-support.html#time-zone-installation