Set MySQL Time Zone

Sometimes your MySQL database’s timezone is set to UTC time by default and does not follow your local timezone. In this case, you’ll need to manually change its configuration.

The configuration file can usually be found in mysql folder, which, depends on the operating system you’re running, could be installed in different directory.

Linux & Mac:

  • /usr/local/mysql/support-files/my.cnf
  • /etc/my.cnf
  • /etc/mysql/my.cnf


  • C:/AppServ/MySQL/my.cnf
  • C:/Program Files/MySQL/MySQL Server 4.1/my.ini

Once you found the config file, open it up with text editor and add this line to the end of the file:

default-time-zone = '+08:00'

In this example, I’m change the time zone to GMT+8.

Next, you need to restart MySQL in order to see the effect. You could do so by opening up command prompt and type in this command:


sudo service mysql restart


net stop MySQL
net start MySQL


sudo /usr/local/mysql/support-files/mysql.server restart

Now your MySQL should run in the correct time zone!

One thought to “Set MySQL Time Zone”

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.