How to set MySQL to use GMT in Windows and Linux

前端 未结 6 1506
春和景丽
春和景丽 2020-12-29 04:58

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 say

6条回答
  •  离开以前
    2020-12-29 05:22

    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.

提交回复
热议问题