How do I set the time zone of MySQL?

 

On one server, when I run:

mysql> select now();
+---------------------+
| now()               |
+---------------------+
| 2009-05-30 16:54:29 |
+---------------------+
1 row in set (0.00 sec)

On another server:

mysql> select now();
+---------------------+
| now()               |
+---------------------+
| 2009-05-30 20:01:43 |
+---------------------+
1 row in set (0.00 sec)

 

And it's actually working as it is supposed to! 🙂 Keep this trick in mind; I haven't seen it to be documented in MySQL manuals and official documentation. But reading the corresponding documentation is must-do thing: MySQL 5.5 timezone official documentation – and don't forget to load timezone data into your server just like that (run as root user!):

mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root mysql

Trick number one – it must be done exactly under MySQL root user. It can fail or produce non-working result even from the user that has full access to a MySQL database – I saw the glitch myself.

 

Reference link
https://dev.mysql.com/doc/refman/5.5/en/time-zone-support.html