How to Change MySQL Server Time Zone

Last modified: July 29, 2020
You are here:
Estimated reading time: 1 min

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

Was this article helpful?
Dislike 0
Views: 21