MySQLのTimeZone設定
- 2014年12月22日
- サーバ構築
MySQLのTimeZone設定方法を説明します。
現在のTimeZoneの確認方法は以下のコマンドで可能です。
show variables like ‘%time_zone%’;
1 2 3 4 5 6 7 8 |
mysql> show variables like '%time_zone%'; +------------------+--------+ | Variable_name | Value | +------------------+--------+ | system_time_zone | PST | | time_zone | SYSTEM | +------------------+--------+ 2 rows in set (0.00 sec) |
設定変更は”/etc/my.cnf”の設定を書き換えればOKです。
vi /etc/my.cnf
1 2 3 4 |
[mysqld_safe] timezone = UTC [mysqld] default-time-zone='+9:00' |
PST: Pacific Standard Time(標準の設定でした。)UTCと8時間違い
JST:日本標準時
UTC:協定世界時
最後にConfigのチェックとプロセスのリスタートを行えば完了です。
/sbin/chkconfig mysqld on
/etc/rc.d/init.d/mysqld restart
1 2 3 4 |
[root@server1 ~]# /sbin/chkconfig mysqld on [root@server1 ~]# /etc/rc.d/init.d/mysqld restart mysqld を停止中: [ OK ] mysqld を起動中: [ OK ] |
コメントを残す