Get your server issues fixed by our experts for a price starting at just 25 USD/Hour. Click here to register and open a ticket with us now!

Author Topic: How to update or change timezone in MySQL  (Read 2154 times)

0 Members and 1 Guest are viewing this topic.

nirmal

  • Jr. Member
  • **
  • Posts: 56
  • Karma: +0/-0
How to update or change timezone in MySQL
« on: December 29, 2013, 01:36:38 pm »
Dear Techies,

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

The below steps will help you to change the MySQL time zone.

1) Check time_zone* tables in mysql db. If it is empty then fill them using following command

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

Zone Info database on system.
Such systems are Linux, FreeBSD, Solaris, and Mac OS X. One likely location for these files is the /usr/share/zoneinfo directory.

2) 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";

The above command will set the timezone to Asia/Calcutta globally.

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.

 If any feedback, queries are always welcome!

Cheers!!!
Get your server issues fixed by our experts for a price starting at just 25 USD/Hour. Click here to register and open a ticket with us now!