LoginSignup
0
0

More than 3 years have passed since last update.

DockerイメージのMySQL5.6と5.7はタイムゾーン設定が異なる

Posted at

MySQL5.6から5.7に移行するにあたって、開発環境を整理していたらDockerイメージのデフォルトのタイムゾーンが変わっていることに気付いた。

MySQL 5.6のタイムゾーン設定

5.6のデフォルトのタイムゾーンは以下の通り設定されていた。

mysql> show variables like '%time_zone%';
+------------------+--------+
| Variable_name    | Value  |
+------------------+--------+
| system_time_zone | UTC    |
| time_zone        | SYSTEM |
+------------------+--------+
2 rows in set (0.00 sec)

そのため、Dockerfileで以下のコマンドを実行して、タイムゾーンを変更していた。

RUN cp -p /usr/share/zoneinfo/Japan /etc/localtime

MySQL 5.7のタイムゾーン設定

5.7のデフォルトのタイムゾーンは以下の通りだった。

mysql> show variables like '%time_zone%';
+------------------+--------+
| Variable_name    | Value  |
+------------------+--------+
| system_time_zone | JST    |
| time_zone        | SYSTEM |
+------------------+--------+
2 rows in set (0.00 sec)

system_time_zoneがロケールの時間帯を採用するように変更されたらしい。
これによって最初から日本時間で処理されるようになった。

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