Mysql

如何解決此錯誤“錯誤 1298 (HY000):未知或不正確的時區:‘UTC’”?

  • December 12, 2020

當我執行以下命令時,我得到一個錯誤,但是我的一個腳本需要它。

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

只需執行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.

瑣事:如果你想知道HY00代表什麼(幾年後我問的後續)……

引用自:https://dba.stackexchange.com/questions/120945