How to change mysql time_zone

System Timezone 确认

1
2
3
date +%Z

// KST
1
2
3
cat /etc/sysconfig/clock

// ZONE=”Asia/Seoul”

System Timezone 设置

1
tzselect
1
ln -sf /usr/share/zoneinfo/Asia/Seoul /etc/localtime

MySQL Timezone 确认

1
2
3
4
mysql> SELECT @@global.time_zone, @@session.time_zone;

// @@global.time_zone | @@session.time_zone
// SYSTEM | SYSTEM
1
2
3
4
5
mysql> show variables like '%time_zone%';

// Variable_name | Value
// system_time_zone | KST
// time_zone | SYSTEM

MySQL Timezone 设置

1
2
3
4
5
mysql> set @@global.time_zone='Asia/Seoul';
mysql> set global time_zone='Asia/Seoul';
mysql> set @@session.time_zone="+09:00";
mysql> set session time_zone ='Asia/Seoul';
mysql> set time_zone = "+09:00";

MySQL Timezone 常用列表

1
2
3
CST
UTC
Asia/Seoul