[How To] Update or Change MySQL database timezone

Sometimes you need to change the timezone used by MySQL database for some  specific applications or globally.

The below steps will guide you to change the MySQL time zone:

1) Check time_zone* tables in mysql database. If it is empty then insert Zone Info data using following command

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

Systems like Linux, FreeBSD, Solaris, and Mac OS X stored zone information at /usr/share/zoneinfo directory.

2) To change / update timezone to Asia/Calcutta globally:
Execute below command as a root user as it needs a super privilege

mysql>SET GLOBAL time_zone = timezone;


mysql>SET GLOBAL time_zone = "Asia/Calcutta";

You can change the time zone as per the requirement.

3) To change the timezone for a user session:

mysql>SET time_zone = timezone;

Click here for the MySQL timezone support manual.

Click here for list of timezones supported.

That's all!

Share on Facebook0Share on Google+0Tweet about this on TwitterShare on StumbleUpon1Share on LinkedIn0Share on Tumblr0Pin on Pinterest0Email this to someonePrint this page

About Abhijit Sandhan

Abhijit Sandhan

Loves Linux, Blogging, Traveling, Hiking and sharing Knowledge!

One comment

  1. thanks but how to check the current time zone ?

Leave a Reply

Your email address will not be published. Required fields are marked *