ASi

OSX 上の MySQL の TimeZone の変え方

公式説明は下記にあるのだが、多少トラップがある。
https://dev.mysql.com/doc/refman/5.7/en/time-zone-support.html

システムテーブルを書き換える

これを行わずに my.cnf にタイムゾーンを指定すると、mysqld が起動しなくなる。
既に DB を作り始めていると、-D を使って DB を指定する必要がある。

/usr/local/mysql-5.7.x-macos10.x-x86_64/bin/mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -h localhost -u root -p -Dmysql

OSX 10.14.6(18G95)では
Warning: Unable to load '/usr/share/zoneinfo/+VERSION' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/zone.tab' as time zone. Skipping it.
が出た。とりあえず無視。

止める

OSX だとシステム環境設定に MySQL アイコンがあり、ダイアログのボタンで起動/停止できる。

sudo vi /etc/mysql/my.cnf

[mysqld_safe]
timezone = UTC

[mysqld]
default-time-zone = UTC

起動して確認。

mysql> show variables like '%time_zone%';
+------------------+-------+
| Variable_name    | Value |
+------------------+-------+
| system_time_zone | JST   |
| time_zone        | UTC   |
+------------------+-------+