mysql NOW() return wrong value whereas global timezone is set +00:00

心已入冬 提交于 2019-12-05 09:04:46

When calling NOW() (and related functions), MySQL converts the computer's system clock to the session timezone:

  • If the system clock is set to 12:30+05:30 and the session timezone is +00:00, the result will be 07:00.

  • If the system clock is set to 17:30+05:00 and the session timezone is +00:00, the result will be 12:30.

However, one can 'fool' MySQL into thinking that the system clock is in a different timezone to that which the operating system believes by using the --timezone command line argument to mysqld_safe:

  • If the system clock is set to 17:30+10:30 and the session timezone is +00:00, but MySQL was started in such a way specifying that the system clock should be understood to be GMT+5, the result will be the same as the second bullet above.

You should therefore check:

  1. That the timezone of the system clock reconciles with the value given in the system_time_zone system variable (if it doesn't, ensure that you are not specifying a --timezone argument to mysqld_safe and that there was no TZ environment variable set when mysqld_safe was invoked);

  2. That the system clock is reporting the correct time in its specified timezone.

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.

1) Change your system time and timezone, if necessary. 2) Open mysql console and put in your timezone, smth like this: SET GLOBAL time_zone = "+04:00"; 3) Restart mysql.

i have tested- SET time_zone='+05:30'; it is working,but i dont have global permission so you try by setting server time +05:30 -> SET GLOBAL time_zone = '+05:30';

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!