

If you are a MySQL SUPER user, you can set the SYSTEM time_zone variable at runtime from the MYSQL> prompt using the following syntax: SET GLOBAL time_zone=timezone

MySQL's default timezone variable can be initialised to a different value at start-up by providing the following command line option: -default-time-zone=timezoneĪlternatively, if you are supplying the value in an options file, you should use the following syntax to set the variable: -default-time-zone='timezone' from the file that is referenced by the symlink /etc/localtime) The SYSTEM value is obtained from an operating system setting (e.g. It should be noted that the MySQL timezone variable's default setting is SYSTEM at MySQL startup. Used only if the time zone information tables in the mysql database 'Europe/Helsinki', 'US/Eastern', or 'MET'. The value can be given as a named time zone, such as The value can be given as a string indicating an offset from UTC, such The value 'SYSTEM' indicates that the time zone should be the same as Timezone values can be given in several formats, none of which are Let me know if you have any issues and I'll update this answer.įrom the MySQL 5.7 documentation (emphasis mine): Remove the echo lines if you don't want any output. MySQL >= 5.6.6Įxecute the following : mysql_config_editor set -login-path=client -host=localhost -user=root -password If you ever want to un-load the timezone info, just execute the following and restart MySQL: TRUNCATE `time_zone` ĭo not DROP these tables or bad things will happen.īased on a user comment below, if you want to have the timezones automatically updated when you update the system, you first need to allow root to log in without being prompted for a password. Note, the time zone info takes up about 5 MB in MySQL. Then, to view a list of time zones, just do the following: USE mysql You could also just add it to a weekly or monthly cron job to do it for you automatically. If you need to continually rely on MySQL time zones, the above command should be executed every time the system time zone is updated. I'm not sure what the equivalent Windows command would be): mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root -p mysql Executing the following command loads the time zone data from the system (Unix-only. This should work fine in many cases, but there are times when it is better to use named time zones, like for not worrying about daylight savings time.

When not loaded, you are limited to converting using offsets (e.g. If it returns a DATETIME (in this case 08:00:00), you have time zones loaded. If you want to test if they are loaded, try executing: SELECT CONVERT_TZ(' 12:00:00', 'GMT', 'America/New_York')

By default, (at least on Debian-based installations) no time zone data is loaded into MySQL.
