26

When I run the following command I get an error, however one of my scripts requires it.

SET time_zone = 'UTC';
ERROR 1298 (HY000): Unknown or incorrect time zone: 'UTC'

3 Answers 3

37

Simply run mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root mysql -p

$ mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root mysql -p
Enter password: 
Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/leap-seconds.list' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/zone.tab' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/zone1970.tab' as time zone. Skipping it.

Trivia: If you want to know what the HY00 stands for (a follow up I asked years later)....

1
  • I am using Ubuntu 20.04 and I got this Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it. Warning: Unable to load '/usr/share/zoneinfo/leap-seconds.list' as time zone. Skipping it. Warning: Unable to load '/usr/share/zoneinfo/leapseconds' as time zone. Skipping it. Warning: Unable to load '/usr/share/zoneinfo/tzdata.zi' as time zone. Skipping it. Warning: Unable to load '/usr/share/zoneinfo/zone.tab' as time zone. Skipping it. Warning: Unable to load '/usr/share/zoneinfo/zone1970.tab' as time zone. Skipping it. Commented Mar 8, 2022 at 21:59
6

As kaiser suggested, the trailing slash is unneeded but without specifying mysql as the database mariadb complains about a missing database. I found that

$ mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root -p -Dmysql

was the correct way to solve the problem in Mariadb 164.

0
1

In case you use MySQL on windows and get the error below

SET time_zone = 'UTC';
ERROR 1298 (HY000): Unknown or incorrect time zone: 'UTC'

From my post on how to resolve this issue:

The issue is you do not have the time zones data installed, to install the time zones on a Windows machine, you will need:

  1. Download "timezone_2020a_posix.zip - POSIX standard" from https://dev.mysql.com/downloads/timezones.html

  2. Stop the MySQL service

  3. Extract the files from the downloaded file and copy them with overwrite to C:\ProgramData\MySQL\MySQL Server 5.6\data\mysql

    Yes, to C:\ProgramData.. and not to C:\Program Files (x86)\MySQL...

  4. Start the MySQL service

2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.