Mysql System Timezone

ZoneServertimezone

SELECT @@systemtimezone; It will return the result set with the name of your Timezone. For example, I am in India and the time zone of my machine is India Standard Time hence the result will contain the same. Let me know if you use any other method to retrieve the Timezone of the server where MySQL is installed. MySQL provides developers with a rich set of Date and Time functions. One of the functions is CONVERTTZ which converts a datetime value from one time zone to another. This function can use named time zones such as 'MET' or 'Europe/Moscow' from the time zone information tables in system database called mysql.

Is it possible to change the time zone in MySQL?

Yes we can change the default time zone in MySQL via command-line. We can’t change the time zone for a single DB, it’s a global change. To change this feature, you must have the root privilege to the server. We have to edit the MySQL configuration file to change the time zone of MySQL server from its default.

By default the MySQL server time is same as the SYSTEM time. We can check this by using the following commands:

Set

To check the server time

>> date

Example

To check MySQL server time

>> mysql -e “SELECT NOW();”

How to change the MySQL server time from command line?

We can change this by adding the following directives to the MySQL configuration file. Please do follow the steps pasted below:

>> Log into server as root user.
>> To check MySQL’s current time zone settings, execute the following command:

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

Example

It means MySQL is using server SYSTEM default time. To change this, you need to add the following directive into the MySQL conf file.

>> “default-time-zone”

1, Open MySQL conf by using your favorite editor;

2, Restart MySQL

That’s it!!! Now check the current MySQL server time by using the command mysql -e “SELECT NOW();”.

Mysql System Time Zone Finder

Mysql System Timezone

Try it and let me know if you have any questions on it.

Mysql System Time Zone Chart

Also read

Mysql System Time Zone Calculator

1, Impossible to create database’s user::MySQL governor
2, Performance tuning script for MySQL – Command-line Mysql Tuner
3, Simple PHP script to check the MySQL database connection from web-browser