mysql操作日志记录查询_详解mysql数据库参数log_timestamps--控制日志记录使用的时区...

概述

最近发现之前安装的MySQL 5.7.27,其中的error log、general log日志里面日志时间的时区不对。

0c41ad46ab01fa2eb115e7daccd26fc0.png

思路:

mysql 5.7.2新增了参数 log_timestamps,用于控制error log、general log、slow log日志记录使用的时区,只影响写入文件的时区,不影响写入表中记录的时区。默认值是UTC,支持设置为SYSTEM使用系统的时区。

• log_timestamps

a8790692bcab0a6b7963c6d5628c76a2.png

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;

执行之后,新的日志的时区就会变成系统默认的时区。

76ed7ff5c56968ef40f27d846ac71477.png

2、永久修改

在my.cnf中添加 log_timestamps=SYSTEM

32afc5c48fa9a00e8b449bf47667db2c.png

觉得有用的朋友多帮忙转发哦!后面会分享更多devops和DBA方面的内容,感兴趣的朋友可以关注下~

2c2f52f11db44fc40e944b8c920317f5.gif
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值