MySQL time zone different from system time zone

In some situations, the system time zone will be different than the one in MySQL, even though MySQL is set to use the system time zone. This normally means that a user has changed the system time zone, but they haven't started MySQL to cause it to change as well.

$ date
Sun Jul  1 11:32:56 CDT 2007
mysql> show variables like '%time_zone%';
+------------------+--------+
| Variable_name    | Value  |
+------------------+--------+
| system_time_zone | PDT    |
| time_zone        | SYSTEM |
+------------------+--------+
2 rows in set (0.00 sec)

If you find yourself in this situation, just restart MySQL and the situation should be fixed:

mysql> show variables like '%time_zone%';
+------------------+--------+
| Variable_name    | Value  |
+------------------+--------+
| system_time_zone | CDT    |
| time_zone        | SYSTEM |
+------------------+--------+
2 rows in set (0.00 sec)
Printed from: http://rackerhacker.com/2007/07/01/mysql-time-zone-different-from-system-time-zone/ .
© Major Hayden 2012.

3 Comments   »

  • Siddhartha says:

    great help . Trivial though but great.

  • Vishwanath says:

    Superb!

  • Lysrin says:

    Thank you! Thank you! I don't know why this didn't occur to me. I had two MySQL server PCs, both configured exactly the same, and I was getting time off by one hour on one of them. I searched for config problems, Windows times issues, poured over MySQL docs, etc. for 2 hours before finding your post. I had forgotten to restart MySQL on the development server after making the Windows time changes on both PCs, and sure enough that was the problem.

    Not trivial at all in my mind! Sometimes the simple solutions are the hardest ones to remember!

    Thanks again.

RSS feed for comments on this post

Leave a Reply

 

  • Welcome! I started this blog as a way to give back to all of the other system administrators who have taught me something in the past. Writing these posts brings me a lot of enjoyment and I hope you find the information useful. If you spot something that's incorrect or confusing, please write a comment and let me know. Drop me a line if there's something you want to know more about and I'll do my best to write a post on the topic.
    -- Major Hayden