Change mysql server time zone

Filed Under (Databases) by jc on 30-03-2009

If you want mysql to have a different timezone than your server’s, here are the steps:

1) Run the following command to populate mysql’s timezone tables:

mysql_tzinfo_to_sql /usr/share/zoneinfo |mysql mysql

2) in the [mysqld] section of /etc/my.cnf, add the following line:

default-time-zone='US/Eastern'
(change US/Eastern with the desired timezone of course. It should match the format of /usr/share/zoneinfo)

3) Restart mysql

To check you mysql server’s time run the following query:

mysql> select now();
+---------------------+
| now()               |
+---------------------+
| 2009-03-30 16:21:20 |
+---------------------+
1 row in set (0.00 sec)

–JC

Leave a Reply