如何解决此错误“ ERROR 1298(HY000):未知或不正确的时区:'UTC'”?


14

当我运行以下命令时,出现错误,但是我的一个脚本需要它。

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

Answers:


16

只需运行 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代表什么(几年后我要求进行跟进)...。


难道尾部的斜杠没有真正被欣赏mysql_tzinfo_to_sql吗?:)
kaiser

5

我会将其添加为已接受答案的注释,但我缺乏所需的声誉。如@kaiser所建议的,不需要尾部斜杠,但无需指定mysql,因为数据库mariadb抱怨缺少数据库。我找到

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

是解决Mariadb 164中问题的正确方法。


1
这似乎为线程增加了一些价值。我给了您+1-我对整个no comments till 50政策有疑问。您可以做的是将自己的“答案”标记为评论-我认为这是推荐的政策?有一个“进入壁垒”,但是也有一个原因
Vérace
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.