日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

MySQL5.7参数log_timestamps

發布時間:2024/1/17 43 豆豆
生活随笔 收集整理的這篇文章主要介紹了 MySQL5.7参数log_timestamps 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

最近測試MySQL 5.7.21? Community Server這個版本的MySQL數據庫時,發現其錯誤日志的時間跟系統當前時間不一致,后面檢查發現日期時間格式都是UTC時間,查了一下相關資料,原來在MySQL 5.7.2 之后日志文件里面的時間戳從默認的本地系統時區改為了UTC格式。MySQL 5.7.2多了一個參數log_timestamps ,這個參數主要是控制錯誤日志、慢查詢日志等日志中的顯示時間。但它不會影響查詢日志和慢日志寫到表 (mysql.general_log, mysql.slow_log) 中的顯示時間。在查詢記錄的時候,可以使用 CONVERT_TZ() 函數,或者設置會話級別的系統變量 time_zone 來轉換成所需要的時區。官方資料詳細介紹如下所示:

?

This variable controls the time zone of timestamps in messages written to the error log, and in general query log and slow query log messages written to files. It does not affect the time zone of general query log and slow query log messages written to tables(mysql.general_log, mysql.slow_log). Rows retrieved from those tables can be converted from the local system time zone to any desired time zone with CONVERT_TZ() or by setting the session time_zone system variable.

Permitted log_timestamps values are UTC (the default) and SYSTEM (local system time zone).

Timestamps are written using ISO 8601 / RFC 3339 format: YYYY-MM-DDThh:mm:ss.uuuuuu plus a tail value of Z signifying Zulu time (UTC) or ±hh:mm (an offset from UTC).

This variable was added in MySQL 5.7.2. Before 5.7.2, timestamps in log messages were written using the local system time zone by default, not UTC. If you want the previous log message time zone default, set log_timestamps=SYSTEM.

?

此參數是全局的,可以動態修改,修改參數log_timestamps的值非常簡單,如下所示,不過最好在參數文件my.cnf設置該參數值,以防MySQL服務重啟失效。

?

?

mysql> show variables like?'log_timestamps';+----------------+-------+| Variable_name? | Value |+----------------+-------+| log_timestamps | UTC?? |+----------------+-------+1 row?in?set (0.01 sec)?mysql> set?global log_timestamps=system;Query OK, 0 rows affected (0.00 sec)?mysql> show variables like?'log_timestamps';+----------------+--------+| Variable_name? | Value? |+----------------+--------+| log_timestamps | SYSTEM |+----------------+--------+1 row?in?set (0.01 sec)?mysql>

?

?

?

參考資料:

?

http://mysql.taobao.org/monthly/2017/01/09/

https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_log_timestamps

總結

以上是生活随笔為你收集整理的MySQL5.7参数log_timestamps的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。