如何设置MySQL在Windows和Linux中使用GMT [英] How to set MySQL to use GMT in Windows and Linux

查看:300
本文介绍了如何设置MySQL在Windows和Linux中使用GMT的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我已经在这里阅读了文档: http://dev.mysql.com/doc/refman/5.1/en/time-zone -support.html



它说要在选项文件中设置:default-time-zone ='timezone'。



然而,我已经搜索了几个不同的术语,找不到可能的值timezone应该是。我也不知道my.ini(和Linux,my.cnf)在哪里放这个指令。下面[msyqld]?

解决方案

转到my.ini文件的[mysqld]部分,在该部分下输入


default-time-zone ='+00:00'


'+ 00:00'表示与GMT的偏移量,在您的情况下为0.请注意字符串中的+号。



您不需要为您的问题安装任何时区表。重新启动服务器后,您的服务器将在UTC时区运行,因此NOW()将以GMT格式给您时间。



默认情况下,MySQL设置为您的SYSTEM时区ie。您的服务器时区与系统时区相同。所以您也可以更改系统时区来解决您的问题,尽管这是不可推荐的。


I'm just trying to get MySQL to store time in GMT...

I've read the documentation here: http://dev.mysql.com/doc/refman/5.1/en/time-zone-support.html

It says to set: default-time-zone='timezone' in an option file.

However, I've googled for several different terms and cannot find possible values "timezone" is supposed to be. I also don't know where in my.ini (and in Linux, my.cnf) to put this directive. Below [msyqld] ?

解决方案

Go to [mysqld] section of your my.ini file and under that section enter this line

default-time-zone = '+00:00'

'+00:00' indicates the offset from GMT which in your case will be 0. Please note the '+' sign in the string.

You don't need to install any timezone tables for your problem. After restarting the server, your server will operate in the UTC timezone and hence NOW() will give you the time in GMT.

By default, MySQL is set to your SYSTEM timezone ie. your server timezone is same as your system timezone. So you could also change your system time zone to solve your problem, though this is not recommendable.

这篇关于如何设置MySQL在Windows和Linux中使用GMT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆