LoginSignup
0
0

MySQL の タイムゾーン をUTCに変更(Mac)

Posted at

背景

time_zone が JST になっている

mysql> SHOW VARIABLES LIKE '%time_zone%';
+------------------+--------+
| Variable_name    | Value  |
+------------------+--------+
| system_time_zone | JST    |
| time_zone        | SYSTEM |
+------------------+--------+

本番環境と揃えるため、time_zone を UTC に変更する

やったこと

  1. my.cnf 探す

    > mysql --help | grep my.cnf
    order of preference, my.cnf, $MYSQL_TCP_PORT,
    /etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf ~/.my.cnf
    

  2. 参考記事によると /etc/my.cnf ファイルを変更

    [mysqld]
    default-time-zone='+00:00'
    

  3. MySQL サーバー再起動し、time_zoneがUTC に変更されたことを確認

    mysql> SHOW VARIABLES LIKE '%time_zone%';
    +------------------+--------+
    | Variable_name    | Value  |
    +------------------+--------+
    | system_time_zone | JST    |
    | time_zone        | +00:00 |
    +------------------+--------+
    

参考

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0