tz命令返回NULL

我有一个convert_tz在mysql中返回null的问题。

mysql --version
mysql  Ver 14.14 Distrib 5.6.11, for osx10.7 (x86_64) using  EditLine wrapper 

我阅读手册http://dev.mysql.com/doc/refman/5.5/en/time-zone-support.html我运行这个命令:bash-3.2#mysql_tzinfo_to_sql / usr / share / zoneinfo | mysql -u root -p mysql输入密码:警告:无法加载'/ usr / share / zoneinfo / + VERSION'作为时区。 跳过它。

Warning: Unable to load '/usr/share/zoneinfo/Asia/Riyadh87' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/Asia/Riyadh88' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/Asia/Riyadh89' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/Mideast/Riyadh87' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/Mideast/Riyadh88' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/Mideast/Riyadh89' as time zone. Skipping it.
ERROR 1406 (22001) at line 38916: Data too long for column 'Abbreviation' at row 1

然后,使用MySQL我跑这个命令。 SELECT CONVERT_TZ('2004-01-01 12:00:00','GMT','EST'); 它返回null。 我可以确认mysql.time_zone_transition_type表格中有GMT和EST条目。


解决此问题的另一种方法是,将mysql_tzinfo导出到文本文件进行编辑:

$ mysql_tzinfo_to_sql /usr/share/zoneinfo > tzinfo.sql

找到有问题的一行,在我的情况下,它是行38982,这是从38982行到38984的一个拆分查询:

INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, Offset, Is_DST,    Abbreviation) VALUES (@time_zone_id, 0, 0, 0, 'Local time zone must be set--see zic manual page');

将其更改为:

INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, Offset, Is_DST, Abbreviation) VALUES (@time_zone_id, 0, 0, 0, 'UNSET');

保存该文件并将其插入到你的mysql数据库中:

$ cat tzinfo.sql | mysql -u root mysql

资料来源:http://dev.mysql.com/doc/refman/4.1/en/time-zone-support.html
使用MacOS 10.9.3,MySQL 5.6.15进行测试


**更新,我解决了这个问题,使用一个Linux框创建sql文件:mysql_tzinfo_to_sql / usr / share / zoneinfo,然后将这个文件导入到我的mac mysql中。

链接地址: http://www.djcxy.com/p/25049.html

上一篇: tz command returns NULL

下一篇: MySQL: How to select the UTC offset and DST for all timezones?