mysql操作日志记录查询_详解mysql数据库参数log_timestamps--控制日志记录使用的时区...
概述
最近發(fā)現(xiàn)之前安裝的MySQL 5.7.27,其中的error log、general log日志里面日志時間的時區(qū)不對。
思路:
mysql 5.7.2新增了參數(shù) log_timestamps,用于控制error log、general log、slow log日志記錄使用的時區(qū),只影響寫入文件的時區(qū),不影響寫入表中記錄的時區(qū)。默認值是UTC,支持設(shè)置為SYSTEM使用系統(tǒng)的時區(qū)。
? log_timestamps
This variable controls the timestamp time zone of error log messages, and of 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.
解決:
1、臨時修改
set global log_timestamps=SYSTEM;執(zhí)行之后,新的日志的時區(qū)就會變成系統(tǒng)默認的時區(qū)。
2、永久修改
在my.cnf中添加 log_timestamps=SYSTEM
覺得有用的朋友多幫忙轉(zhuǎn)發(fā)哦!后面會分享更多devops和DBA方面的內(nèi)容,感興趣的朋友可以關(guān)注下~
總結(jié)
以上是生活随笔為你收集整理的mysql操作日志记录查询_详解mysql数据库参数log_timestamps--控制日志记录使用的时区...的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python关系运算符可以连续使用_py
- 下一篇: c++ standard library