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