Mysql5.7错误日志时间不对的解决办法

 MySQL 5.7的错误日志时间和系统时间不一致,看起来费劲,查阅官方文档得知MySQL 5.7.2 开始,新增了 log_timestamps 参数,它主要是控制 error log、genera log等日志文件的显示时间参数:
官文如下:

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. (root@localhost) [(none)]> show global variables like 'log_timestamps';
  2. +----------------+-------+
  3. | Variable_name | Value |
  4. +----------------+-------+
  5. | log_timestamps | UTC |
  6. +----------------+-------+
  7. 1 row in set (0.01 sec)

  8. (root@localhost) [(none)]> set global log_timestamps=SYSTEM;
  9. Query OK, 0 rows affected (0.00 sec)

  10. (root@localhost) [(none)]> SHOW global variables like 'log_timestamps';
  11. +----------------+--------+
  12. | Variable_name | Value |
  13. +----------------+--------+
  14. | log_timestamps | SYSTEM |
  15. +----------------+--------+
  16. 1 row in set (0.01 sec)





来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/20893244/viewspace-2132032/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/20893244/viewspace-2132032/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值