InMotion Hosting Support Center

In this article we'll discuss how you can change the MySQL time zone on your server so that data stored in your databases will by default use the time zone that you have specified.

A lot of the time your local time zone will be different than the MySQL server's time zone, and this could make working with data inside your databases more difficult for you. Using the following steps you can update your MySQL server's time zone so that it matches your own to make working with this data easier.

This change would require root access to either a VPS (Virtual Private Server) or dedicated server hosting plan, or you can contact our support department to have this changed on your server. You might also simply need to know how to convert MySQL time which wouldn't require root access and can be done on a shared server.

Changing the Time Zone in MySQL

  1. Login to your server via SSH as the root user.
  2. You can view MySQL's current time zone settings using the following command from the console:

    mysql -e "SELECT @@global.time_zone;"

    By default you should get back something similar to:

    | @@global.time_zone |
    | SYSTEM             |

    This is because by default your MySQL time zone will be set to the server's default SYSTEM time. If you're interested in changing the entire server's time zone this can be accomplished by setting the time zone in WHM.

  3. You can see the server's SYSTEM time stamp using the following command:


    Which will give back:

    Mon Nov 26 12:50:07 EST 2012

  4. You can see the current time stamp reported by the MySQL server using the following command:

    mysql -e "SELECT NOW();"

    This should give back the current time stamp:

    | NOW()               |
    | 2012-11-26 12:50:15 |
  5. Now you can edit your MySQL configuration file with your favorite text editor:

    vi /etc/my.cnf

    Then add the following line to change from EST (GMT -5:00) to CST (GMT -6:00):

    default-time-zone = '-06:00'

    Now save the /etc/my.cnf file with your new default.

  6. To make the change active you'll want to restart the MySQL service with the following command:

    service mysql restart

  7. Now if you try to see the global time zone setting again with the command:

    mysql -e "SELECT @@global.time_zone;"

    You should now get back your new default:

    | @@global.time_zone |
    | -06:00             |
  8. You should also see now that the NOW() function has updated as well:

    mysql -e "SELECT NOW();"

    This should give back the current time stamp:

    | NOW()               |
    | 2012-11-26 11:50:15 |

You should now know how to update the MySQL server's time zone setting, to help make sure the data stored in databases is easy for you to work with. You can also used named time zones instead of the GMT -6:00 format, but this would first require you loading the time zone tables into the mysql database. More information on this can be found on the MySQL site regarding mysql_tzinfo_to_sql and loading the time zone tables.

Was this article helpful?

Related Questions

Here are a few questions related to this article that our customers have asked:
Ooops! It looks like there are no questions about this page.
Would you like to ask a question about this page? If so, click the button below!
Ask a Question

Forum Login

You are NOT logged in. You can still browse our Support Center.

To participate within our Community Support Forum:

n/a Points
2018-07-31 9:53 am
I've added the following in my.cnf file:
default-time-zone = '+05:30'
Tried to restart and it says job for mysql.service failed. Do I need to do it on server or this can even be done from Putty? I am doing this on Putty. Please help.
11,000 Points
2018-07-31 10:21 am
There are many possible reasons for the service failure. It could be something like a syntax error or something more systemic. I'd advise contacting our Live Support so they can replicate the issue in your server environment.
n/a Points
2018-05-10 8:40 pm

How do we invoke the service mysql restart command if we are sharing the server with others?

3,737 Points
2018-05-11 10:52 am
Restarting MySQL requires root access to either a VPS (Virtual Private Server) or dedicated server. You can convert MySQL time by following our guide here.

It's worth noting that if your shared server begins with "ec" for example ecbiz123, then your server is located on the East Coast Data Center, thus the server time zone (used for MySQL as default as well) would be the Eastern Standard Time (EST). If your shared server does not begin with "ec" for example biz124 then it is located in our West Coast Data Center, thus the server time zone would be Pacific Standard Time (PST).

If you prefer a specific time zone, you can always contact our Technical Support team to request a move to your preferred Data Center.
n/a Points
2016-04-01 5:00 pm

It worked like charm.

Thank You Very Much!

n/a Points
2015-09-17 9:49 pm

For anyone reading this, my.cnf should look something like this (unless you have other configurations):


default-time-zone = 'Etc/UTC'


n/a Points
2015-03-19 5:40 am
nice its helpfull to me. Thanks
n/a Points
2014-06-27 4:46 am

$ sudo service mysql starterror: Found option without preceding group in config file: /etc/my.cnf at line: 1Fatal error in defaults handling. Program aborted

31,539 Points
2014-06-27 7:56 am
Hello SanX,

Thank you for contacting us. I am not sure what you are asking, but we are happy to help.

Can you provide more details, such as a link to the error, or the steps you are taking to see it?

What type of CMS are you using? For example Joomla, Wordpress, Concrete5, etc.

If you have any further questions, feel free to post them below.
Thank you,

n/a Points
2017-12-29 4:20 am

to resolve my problem, i need to check what is time zone of my mysql server in the form of GMT+0700 or Europe/Berlin. Though elaborated, yet article not helpu ful to get this info, can you please guide?



11,000 Points
2017-12-29 12:39 pm
Are you trying to find the timezone in that format or change it to that format?

Post a Comment

Email Address:
Phone Number:

Please note: Your name and comment will be displayed, but we will not show your email address.

14 Questions & Comments

Post a comment

Back to first comment | top

Need more Help?


Ask the Community!

Get help with your questions from our community of like-minded hosting users and InMotion Hosting Staff.

Current Customers

Chat: Click to Chat Now E-mail:
Call: 888-321-HOST (4678) Ticket: Submit a Support Ticket

Not a Customer?

Get web hosting from a company that is here to help. Sign up today!