修改MySQL的時區,涉及引數time zone

2021-09-10 07:04:17 字數 3581 閱讀 5046

首先需要檢視mysql的當前時區,用time_zone引數

mysql> show variables like '%time_zone%';   +------------------+--------+| variable_name    | value  |+------------------+--------+| system_time_zone | cst    || time_zone        | system |+------------------+--------+2 rows in set (0.00 sec)

set time_zone = timezone比如北京時間(gmt+0800)set time_zone = '+8:00'; 如下:mysql> set time_zone='+8:00';query ok, 0 rows affected (0.00 sec)mysql> show variables like '%time_zone%';   +------------------+--------+| variable_name    | value  |+------------------+--------+| system_time_zone | cst    || time_zone        | +08:00 |+------------------+--------+2 rows in set (0.00 sec)

3 再通過select now()來驗證時區

mysql> show variables like '%time_zone%';   +------------------+--------+| variable_name    | value  |+------------------+--------+| system_time_zone | cst    || time_zone        | +08:00 |+------------------+--------+2 rows in set (0.00 sec)mysql> select now();+---------------------+| now()               |+---------------------+| 2013-08-05 10:35:31 |+---------------------+1 row in set (0.00 sec)mysql>  set time_zone='+0:00';query ok, 0 rows affected (0.00 sec)
mysql> show variables like '%time_zone%';+------------------+--------+| variable_name    | value  |+------------------+--------+| system_time_zone | cst    || time_zone        | +00:00 |+------------------+--------+2 rows in set (0.00 sec)
mysql> select now();+---------------------+| now()               |+---------------------+| 2013-08-05 02:35:43 |+---------------------+1 row in set (0.00 sec)

再分享一下我老師大神的人工智慧教程吧。零基礎!通俗易懂!風趣幽默!還帶黃段子!希望你也加入到我們人工智慧的隊伍中來!

首先需要檢視mysql的當前時區,用time_zone引數

mysql> show variables like '%time_zone%';   +------------------+--------+| variable_name    | value  |+------------------+--------+| system_time_zone | cst    || time_zone        | system |+------------------+--------+2 rows in set (0.00 sec)

set time_zone = timezone比如北京時間(gmt+0800)set time_zone = '+8:00'; 如下:mysql> set time_zone='+8:00';query ok, 0 rows affected (0.00 sec)mysql> show variables like '%time_zone%';   +------------------+--------+| variable_name    | value  |+------------------+--------+| system_time_zone | cst    || time_zone        | +08:00 |+------------------+--------+2 rows in set (0.00 sec)

3 再通過select now()來驗證時區

mysql> show variables like '%time_zone%';   +------------------+--------+| variable_name    | value  |+------------------+--------+| system_time_zone | cst    || time_zone        | +08:00 |+------------------+--------+2 rows in set (0.00 sec)mysql> select now();+---------------------+| now()               |+---------------------+| 2013-08-05 10:35:31 |+---------------------+1 row in set (0.00 sec)mysql>  set time_zone='+0:00';query ok, 0 rows affected (0.00 sec)
mysql> show variables like '%time_zone%';+------------------+--------+| variable_name    | value  |+------------------+--------+| system_time_zone | cst    || time_zone        | +00:00 |+------------------+--------+2 rows in set (0.00 sec)
mysql> select now();+---------------------+| now()               |+---------------------+| 2013-08-05 02:35:43 |+---------------------+1 row in set (0.00 sec)

修改MySQL的時區 涉及引數time zone

分享一下我老師大神的人工智慧教程!零基礎,通俗易懂!首先需要檢視mysql的當前時區,用time zone引數 mysql show variables like time zone variable name value system time zone cst time zone system ...

mysql 時區修改

檢視資料庫時區 mysql show variables like time zone variable name value system time zone est time zone system 2 rows in set 0.00 sec mysql預設使用的system時區,即est時區...

修改mysql時區

通過mysql命令列模式下動態修改 1.1 檢視mysql當前時間,當前時區 select curtime 或selectnow 也可以 curtime 15 18 10 show variables like time zone variable name value system time zo...