A
A
avorobiev2011-11-07 22:46:56
MySQL
avorobiev, 2011-11-07 22:46:56

Wrong time zone in MySQL?

In MySQL, the time is one hour behind than in the system. Why is not clear.
The problem manifested itself only on 1 server with the following configuration:
OS - Debian GNU/Linux 6.0.3 (squeeze)
MySQL - 5.1.49
The current time and time zone are correctly configured in the system:

$ date<br/>
Mon Nov 7 16:49:10 MSK 2011

The tzdata package has been updated to the latest available:
# apt-cache policy tzdata<br/>
tzdata:<br/>
 Installed: 2011m-0squeeze1<br/>
 Candidate: 2011m-0squeeze1<br/>
 Version table:<br/>
 *** 2011m-0squeeze1 0<br/>
 500 <a href="http://mirror.yandex.ru/debian/">mirror.yandex.ru/debian/</a> squeeze-updates/main amd64 Packages<br/>
 100 /var/lib/dpkg/status<br/>
 2011k-0squeeze1 0<br/>
 500 <a href="http://mirror.yandex.ru/debian/">mirror.yandex.ru/debian/</a> squeeze/main amd64 Packages

However, in MySQL, the time is one hour less than in the system:
mysql&gt; select NOW();<br/>
+---------------------+<br/>
| NOW() |<br/>
+---------------------+<br/>
| 2011-11-07 15:49:10 |<br/>
+---------------------+<br/>
1 row in set (0.00 sec)

Although nowhere: neither in the settings /etc/mysql/my.cnf, nor at the start of mysql, the system time zone does not overlap:
mysql&gt; SELECT @@global.time_zone, @@session.time_zone;<br/>
+--------------------+---------------------+<br/>
| @@global.time_zone | @@session.time_zone |<br/>
+--------------------+---------------------+<br/>
| SYSTEM | SYSTEM |<br/>
+--------------------+---------------------+<br/>
1 row in set (0.00 sec)

However, the system time and the time in mysql are different :-( - in mysql the time is incorrect, an hour less.
I found one oddity in MySQL:
mysql&gt; SHOW GLOBAL VARIABLES LIKE '%time_zone%';<br/>
+------------------+--------+<br/>
| Variable_name | Value |<br/>
+------------------+--------+<br/>
| system_time_zone | MSD |<br/>
| time_zone | SYSTEM |<br/>
+------------------+--------+<br/>
2 rows in set (0.00 sec)

When it was summer time, there were 2 time zones for Moscow: winter - MSK (UTC + 3) and summer - MSD (UTC + 4).
After canceling the transition to winter time, only 1 zone should remain - MSK, and it should be UTC + 4.
I have MSD instead of MSK in MySQL, while MSD for some reason is equal to UTC + 3, and not UTC + 4 as it was before 10.30. Where did the MSD time zone come from, if MSK is set in the system, it is not clear.
MySQL mysql:time_* tables are empty. Those. time zones should be used system.
What needs to be done so that MySQL has the correct time, the same as in the system?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
C
chmv, 2011-11-07
@avorobiev

Try the newer tzdata 2011n-1 (from testing).

V
Vladimir Chernyshev, 2011-11-08
@VolCh

Hmm, the same version of OS and MySQL, but everything is fine - system_time_zone issues MSK.
Here is another tzdata Now it will even be somehow scary to be updated :-/
apt-cache policy tzdata
tzdata:
Установлен: 2011k-0squeeze1
Кандидат: 2011k-0squeeze1
Таблица версий:
*** 2011k-0squeeze1 0
500 mirror.hetzner.de/debian/packages/ squeeze/main amd64 Packages
500 ftp.uni-bayreuth.de/linux/Debian/debian/ squeeze/main amd64 Packages
100 /var/lib/dpkg/status

S
Sergey Fedotov, 2011-11-08
@FSA

Restart the service after updating tzdata. I also had less time on FreeBSD than on the system. saved
#service mysql-server restart

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question