Mysql:如何诊断和纠正错误的时区
在我的服务器中,我从命令行得到以下内容:
]$ date
Fri Sep 16 13:47:02 JST 2011
这是正确的。
在mysql中,我有以下内容:
mysql> select now();
+---------------------+
| now() |
+---------------------+
| 2011-09-16 04:50:21 |
+---------------------+
1 row in set (0.00 sec)
mysql> SELECT @@global.time_zone, @@session.time_zone;
+--------------------+---------------------+
| @@global.time_zone | @@session.time_zone |
+--------------------+---------------------+
| SYSTEM | SYSTEM |
+--------------------+---------------------+
1 row in set (0.00 sec)
那么,它被设置为系统时间,但为什么不显示相同的时间?
In my server, I have the following from the command line:
]$ date
Fri Sep 16 13:47:02 JST 2011
Which is correct.
in mysql, I have the following:
mysql> select now();
+---------------------+
| now() |
+---------------------+
| 2011-09-16 04:50:21 |
+---------------------+
1 row in set (0.00 sec)
mysql> SELECT @@global.time_zone, @@session.time_zone;
+--------------------+---------------------+
| @@global.time_zone | @@session.time_zone |
+--------------------+---------------------+
| SYSTEM | SYSTEM |
+--------------------+---------------------+
1 row in set (0.00 sec)
So, it is set to the system time, but then why is not showing the same time?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
更改系统时区后,只需重新启动mysqld即可。MySQL
的全局时区采用系统时区。当你改变系统的任何此类属性时,你只需要重新启动Mysqld。
就是这样。
You just need to restart mysqld after altering timezone of System..
The Global time zone of MySQL takes timezone of System. When you change any such attribute of system, you just need a restart of Mysqld.
That's it.
您的查询返回 UTC 格式的值,但从命令行输出来看,您的系统采用的是 JST 格式。由于变量返回 SYSTEM,我建议您的配置可能已将系统识别为 UTC。按照此处的建议检查您的 my.cnf 如何我应该让 MySQL 的 NOW() 和 CURDATE() 函数使用 UTC 吗?。
Your queries are returning the values in UTC but from the command line output your system is in JST. Since the variables are returning SYSTEM I would suggest that perhaps your configuration has identified system as UTC. Check out your my.cnf as suggested here How do I make MySQL's NOW() and CURDATE() functions use UTC?.