본문 바로가기

카테고리 없음

MYSQL 한국시간 TIMEZONE 설정

1. MYSQL접속 후 Seoul이 들어가는 시간대 검색

select b.name,a.time_zone_id
from mysql.time_zone a, mysql.time_zone_name b
where a.time_zone_id = b.time_zone_id
and b.name like '%Seoul';

MySQL에 있는 시간대 검색

select count(*) from mysql.time_zone;

시스템 시간대 검색

select @@system_time_zone;

 

따로 서울의 시간대가 없는 모습.

 

 

 

2. 서울의 시간대가 없다면 삽입해준다.

 

MySQL에서 나온 후 root권한으로 다음 명령어 실행

# mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root -p mysql

 

 

 

 

time_zone에 들어왔나 확인

select b.name,a.time_zone_id
from mysql.time_zone a, mysql.time_zone_name b
where a.time_zone_id = b.time_zone_id
and b.name like '%Seoul';

 

 

 

 

 

3. 시간대를 아시아/서울로 설정

set time_zone='Asia/Seoul';

set GLOBAL time_zone='Asia/Seoul';

 

시간변경 확인

select now();

 

 

4. MySQL 서버 재구동 후 변화 확인

# systemctl restart mysql