How to Change MySQL Server Time Zone

Posted on February 1st, 2017

In this article, we can discuss about how to change the MySQL server time zone. To change the time zone of your MySQL server, please follow the below steps.

 

1) Login to your server via SSH as root user.

2) You can find current MySQL server time zone via executing the following command.

$ mysql  -e “SELECT @@global.time_zone;”

The output of the above command is something similar to the following:

@@global.time_zone

SYSTEM

Here we can see that the MySQL time zone is set as “System”. Which means current MySQL time zone depends on the system time.

By default, MySQL time zone will be set to the server’s time zone. If you are interested in changing MySQL Time zone you can edit /etc/my.cnf configuration file.

 

3) You can check the server’s current time using following command:

$ date

The date command will give back something similar to the following:

Mon Nov 26 12:50:07 EST 2017

 

4) You can check current timestamp using in MySQL by executing the following command:

$ mysql -e “SELECT NOW();”

The command will give back something like:

NOW()

2017-11-26 12:50:15

 

5) You can change your MySQL time zone by editing MySQL configuration file (/etc/my.cnf). You need to open the config. file using your favorite text editor.

$ vi /etc/my.cnf

Then add the time zone details to the bottom of the configuration file. For example:

default-time-zone = ‘-06:00’

 

6) Run the following command to check if time zone has changed.

$ mysql -e “SELECT @@global.time_zone;”

 

7) You should also check with the NOW function.

$ mysql -e “SELECT NOW();”

Now we can discuss about how to change the server time zone via WHM.

 

Change server time zone in WHM

1) Login to WHM.

2) Click on the icon “Server configuration”.

timezone change

 

3) Click on “Server Time”.

Server Time Zone

 

4) From the dropdown menu, Select the time zone.

Server Time Zone

 

5) Click on “Sync Time with Time Server”.

Server Time Zone

 

If you need any further assistance please contact our support department.

 

 

One Response to “How to Change MySQL Server Time Zone”

  1. Rosie-ubq says:

    The server has a specific time setting. This is usually based on the servers physical location, for example, if the datacenter that houses the server is located in California, the server will most likely be set to the Pacific Time. Some sites may cater to specific areas of the world and wish to use the timezone for that area. PHP has configuration files that can do this, but what about other tiles such as HTML or Log files? That is where the htaccess comes into play. Below are instructions for changing the base timezone in your local htaccess file.

Leave a Reply