Hodustory/프로그래밍&DB

[에러] mySQL timeZone 한국 설정 (우분투 리눅스)

호두밥 2020. 2. 7. 12:46

mysql 5.7

Ubuntu Linux 18

timezone 한국으로 설정 중 ERROR 1298(HY000) : Unknown or incorrect time zone : 'Asia/Seoul' 발생

 

아래의 코드를 한줄씩 실행

root@test ~# >  mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root -p mysql

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.

root@test ~# > mysql_tzinfo_to_sql  /usr/share/zoneinfo/Asia/Seoul KST
INSERT INTO time_zone_transition_type (Time_zone_id, Transition_type_id, Offset, Is_DST, Abbreviation) VALUES (@time_zone_id, 0, 30472, 0, 'LMT') ,(@time_zone_id, 1, 30600, 0, 'KST') ,(@time_zone_id, 2, 32400, 0, 'JST') ,(@time_zone_id, 3, 36000, 1, 'KDT') ,(@time_zone_id, 4, 32400, 0, 'KST') ,(@time_zone_id, 5, 34200, 1, 'KDT') ,(@time_zone_id, 6, 36000, 1, 'KDT')
root@test ~# > mysql
mysql >  set time_zone = 'Asia/Seoul';
mysql > select @@time_zone;
mysql> set time_zone = 'Asia/Seoul'; Query OK, 0 rows affected (0.00 sec)
mysql> select @@time_zone;
+-------------+ 
|@@time_zone |
+-------------+
|  Asia/Seoul  |
+-------------+
1 row in set (0.00 sec)

이 설정을 영구적으로 반영하기 위해서는 mysqld.cnf 파일의 설정을 기입해야 함.

root@test ~# > vi /etc/mysql/mysql.conf.d/mysqld.cnf

default-time-zone=Asia/Seoul 을 맨 아래에 적어넣음

 

추가내용

우분투 리눅스 tomcat 서버 시간 + 한국으로 설정하기

cp /usr/share/zoneinfo/Asia/Seoul /etc/localtime

 

반응형