mysql 時區更改

早上同事在問我我昨天匯給他的 MySQL 時區沒有改,看了一下我原來以為 DB 的 now()是會抓 OS 所以看了一下文件才知道原來DB的 time_zone 也要改, 改了後就可以了。記錄一下

mysql> select now();
+---------------------+
| now()               |
+---------------------+
| 2019-10-07 02:58:28 |
+---------------------+
1 row in set (0.00 sec)

mysql> SET GLOBAL time_zone = '+08:00';
Query OK, 0 rows affected (0.00 sec)

mysql> select now();
+---------------------+
| now()               |
+---------------------+
| 2019-10-07 02:59:20 |
+---------------------+
1 row in set (0.00 sec)

mysql> SET SESSION time_zone = '+08:00';
Query OK, 0 rows affected (0.00 sec)

mysql> select now();
+---------------------+
| now()               |
+---------------------+
| 2019-10-07 10:59:44 |
+---------------------+
1 row in set (0.00 sec)

mysql> quit

Author: jerryw1974

learning and focus on computer science, cloud infrastructure, virtualization and information security, technical, networking,platform system and cyber-security related topic.