2013-07-29 4 views
3

mysql에서 null을 반환하는 convert_tz에 문제가 있습니다. mysql convert_tz 명령이 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 항목이 있음을 확인할 수 있습니다.

답변

0

** 업데이트, 리눅스 상자를 사용하여 mysql_tzinfo_to_sql/usr/share/zoneinfo 파일을 만든 다음이 파일을 mymac mysql으로 가져 왔습니다.

16

또 다른 방법은이 문제를 해결하기 편집에 대한 TEXTFILE에 mysql_tzinfo를 내보내려면 : 내 경우,

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

가 문제가있는 행을 찾기이었다 라인 38982에에서 스플릿 쿼리이었다 라인 38982,

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

파일을 저장하고 : 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'); 

변경을 MySQL 데이터베이스에 삽입 :

$ cat tzinfo.sql | mysql -u root mysql 

출처 : http://dev.mysql.com/doc/refman/4.1/en/time-zone-support.html
맥 OS 10.9.3, MySQL은 5.6.15

+4

'mysql_tzinfo_to_sql를는/usr/share/zoneinfo 표준과 테스트 | sed -e "s/현지 표준 시간대를 설정해야합니다 - zic 매뉴얼 페이지/local /"| mysql -u root mysql은 한 줄에서 같은 것을하는 것처럼 보입니다. 우분투에서 나를 위해 일했다 14.04. –

관련 문제