MySQL5.7 error log时间显示问题
2016-11-16 00:00
573 查看
问题现象:MySQL日志记录时间和系统时间不一致
当前系统时间
MySQL显示时间
日志显示时间
问题原因:
看看官方的解释吧
大概意思是这样的,这个参数是5.7.2引进来的,主要控制记录日志的时间戳,不影响general log和slow log写表。
解决办法:
它的默认设置是UTC,如果你想改变默认设置,set log_timestamps=SYSTEM就可以了。注意这个变量的作用域是global
当前系统时间
[root@bogon data]# date Wed Nov 16 14:48:31 CST 2016 You 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 start Starting 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_pool 2016-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 key 2016-11-16T06:49:38.440314Z 0 [Note] Server hostname (bind-address): '*'; port: 3306 2016-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:38 2016-11-16T06:49:38.871533Z 0 [Note] Event Scheduler: Loaded 0 events 2016-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_timestamps Introduced 5.7.2 Command-Line Format --log_timestamps=# System Variable Name log_timestamps Variable Scope Global Dynamic Variable Yes Permitted Values Type enumeration Default UTC Valid Values UTC SYSTEM 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.
大概意思是这样的,这个参数是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 away No connection. Trying to reconnect... Connection id: 3 Current 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)
相关文章推荐
- [原创]一个AIX FTP文件名显示错误带时间的问题
- 浅析GridView中显示时间日期格式的问题
- Json化后的时间类型数据在Extjs Grid中的显示问题
- (2010-07-14)关于Oracle中设置缺省时间显示格式的问题
- GridView中显示时间日期格式问题
- # 时间显示文字问题的修正 #
- .NET 时间显示问题-读不出数据库中的时间
- asp.net 关于C#时间24进制显示问题
- 解决QQ2009在win7中时间显示错误问题
- 模态窗体弹出显示运行时间出问题
- gridview问题解答 :按钮的Enalbe状态 / 首页\尾页\上一页等 / 显示短时间,年\月\日 / 数据库存是1和0,显示为男和女等!
- GridView中显示时间日期格式问题
- Windows没有北京时间(GMT+8时区)的问题,及QQ聊天栏中显示的时间错误的问题解决办法
- [技术] 在水晶报表(Crystal Report)中时间日期显示的问题
- 修正Raize的时间日期控件不能正确显示星期几的问题
- [原创]一个AIX FTP文件名显示错误带时间的问题
- 奇怪的问题:在IE6中显示FTP中的文件修改时间少一年
- TFS2008上传附件后显示修改时间问题!
- 不同种类日志的显示时间的问题
- ORACLE 插入时间时显示'无效的月份'的问题