博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
MySQL5.7 error log时间显示问题
阅读量:7181 次
发布时间:2019-06-29

本文共 3390 字,大约阅读时间需要 11 分钟。

hot3.png

问题现象:MySQL日志记录时间和系统时间不一致

当前系统时间

[root@bogon data]# dateWed Nov 16 14:48:31 CST 2016You have new mail in /var/spool/mail/root

MySQL显示时间

root@localhost [(none)]>select now();+---------------------+| now()               |+---------------------+| 2016-11-16 14:52:05 |+---------------------+1 row in set (0.00 sec)

日志显示时间

[root@bogon data]# /etc/init.d/mysqld startStarting MySQL.... SUCCESS! You have new mail in /var/spool/mail/root[root@bogon data]# tailf error.log 2016-11-16T06:49:38.202954Z 0 [Note] InnoDB: Loading buffer pool(s) from /data/mysql/mysql3306/data/ib_buffer_pool2016-11-16T06:49:38.440257Z 0 [Warning] Failed to set up SSL because of the following SSL library error: SSL context is not usable without certificate and private key2016-11-16T06:49:38.440314Z 0 [Note] Server hostname (bind-address): '*'; port: 33062016-11-16T06:49:38.440426Z 0 [Note] IPv6 is available.2016-11-16T06:49:38.440443Z 0 [Note]   - '::' resolves to '::';2016-11-16T06:49:38.440471Z 0 [Note] Server socket created on IP: '::'.2016-11-16T06:49:38.627893Z 0 [Note] InnoDB: Buffer pool(s) load completed at 161116 14:49:382016-11-16T06:49:38.871533Z 0 [Note] Event Scheduler: Loaded 0 events2016-11-16T06:49:38.871938Z 0 [Note] /usr/local/mysql/bin/mysqld: ready for connections.Version: '5.7.14-log'  socket: '/tmp/mysql3306.sock'  port: 3306  MySQL Community Server (GPL)

 

 

问题原因:

看看官方的解释吧

log_timestampsIntroduced	5.7.2Command-Line Format	--log_timestamps=#System Variable	Name	log_timestampsVariable Scope	GlobalDynamic Variable	YesPermitted Values	Type	enumerationDefault	UTCValid Values	UTCSYSTEMThis 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.

大概意思是这样的,这个参数是5.7.2引进来的,主要控制记录日志的时间戳,不影响general log和slow log写表。

 

 

解决办法:

它的默认设置是UTC,如果你想改变默认设置,set log_timestamps=SYSTEM就可以了。注意这个变量的作用域是global

root@localhost [(none)]>SHOW GLOBAL VARIABLES LIKE 'log_timestamps';ERROR 2006 (HY000): MySQL server has gone awayNo connection. Trying to reconnect...Connection id:    3Current database: *** NONE ***+----------------+-------+| Variable_name  | Value |+----------------+-------+| log_timestamps | UTC   |+----------------+-------+1 row in set (0.01 sec)root@localhost [(none)]>set global log_timestamps=SYSTEM;Query OK, 0 rows affected (0.00 sec)root@localhost [(none)]>SHOW GLOBAL VARIABLES LIKE 'log_timestamps';+----------------+--------+| Variable_name  | Value  |+----------------+--------+| log_timestamps | SYSTEM |+----------------+--------+1 row in set (0.00 sec)

 

转载于:https://my.oschina.net/u/3023401/blog/789125

你可能感兴趣的文章
free 一个指针时【 retval = HeapFree(_crtheap, 0, pBlock);】报错的原因
查看>>
网易微专业大数据工程师
查看>>
查看、修改oracle字符集,查看oracle版本
查看>>
JavaScript引用类型之Array数组的栈方法与队列方法
查看>>
ASP.NET Core 中文文档 第四章 MVC(3.8)视图中的依赖注入
查看>>
路由器实操 能够登陆QQ 收发信息正常 但游览器无法连接网页
查看>>
vi实战记录
查看>>
less初探
查看>>
关于SQL中的Update语句
查看>>
五、excel末尾补0和开头补0
查看>>
jquery中使用event.target的几点
查看>>
Hybird-App离线缓存系统
查看>>
探索两种优雅的表单验证——策略设计模式和ES6的Proxy代理模式
查看>>
Linux系统如何低于TCP洪水攻击
查看>>
【117天】尚学堂高琪Java300集视频精华笔记(13-17)
查看>>
redis数据迁移
查看>>
NodeJS文档之Module(1)-Module的简介
查看>>
使用User authentication and permissions
查看>>
Yii2 数据库复制和读写分离
查看>>
Facebook 将关闭旗下云端服务器 Parse
查看>>