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!!!