mysqlがnow()で取得した時間が間違っています

3188 ワード

まずnow()でシステム時間を取得し、発見時間が間違っている(差8時間):
mysql> select now();
+---------------------+
| now()               |
+---------------------+
| 2019-04-25 14:44:46 |
+---------------------+

さらに、linuxシステムおよびmysqlのタイムゾーン設定を確認します(system_time_zoneはlinuxシステム設定のタイムゾーン、time_zoneはmysql設定のタイムゾーン):
mysql> show variables like "%time_zone%";
+------------------+--------+
| Variable_name    | Value  |
+------------------+--------+
| system_time_zone | xxx    |
| time_zone        | yyy    |
+------------------+--------+

================= ================================

1、 time_zone SYSTEM:
vi /etc/my.cnf 
 [mysqld]default-time_zone = 'SYSTEM'
2、     linux        :

CentOS 7システム時間と実時間の差8時間
 
 
 

 
転載先:https://www.cnblogs.com/apeway/p/10768458.html