[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;

Example:

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 Facebook0
Share on Google+3Tweet about this on TwitterShare on StumbleUpon1Share on LinkedIn0Share on Tumblr0Digg thisPin on Pinterest0Share on Reddit0Email this to someonePrint this page
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; Example: mysql>SET GLOBAL…

Review Overview

User Rating: 3.08 ( 2 votes)

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 *

CAPTCHA