MySQL 5.7 时间显示修改(log_timestamps UTC)
https://blog.csdn.net/leshami/article/details/78952842
在MySQL 5.7版本中,日志记录时间发生了变化,使用了UTC方式来记录日志时间,也就是说这是个世界统一时间,与我们常用的本地时间不协调,因此,初始化MySQL 5.7之后,需要对此做出调整,如下本文的描述。
一、错误日志的时间格式
当前环境
[robin@ydq-mnt ~]$ more /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)
[robin@ydq-mnt ~]$ mysql -V
mysql Ver 14.14 Distrib 5.7.19-17, for Linux (x86_64) using 6.2
[root@ydq-mnt ~]# date ###系统时间
Mon Dec 18 14:23:16 CST 2018
[root@ydq-mnt ~]# more /var/log/mysqld.log ###mysql 日志输出信息
2017-12-18T07:50:40.575098Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated.
Please use --explicit_defaults_for_timestamp server option (see do
cumentation for more details).
2017-12-18T07:50:40.576375Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.19-17-57-log) starting as process 9268 ...
2017-12-18T07:50:40.578287Z 0 [Warning] No argument was provided to --log-bin, and --log-bin-index was not used;
so replication may break when this MySQL serve
r acts as a master and has his hostname changed!! Please use '--log-bin=ydq-mnt-bin' to avoid this problem.
2017-12-18T07:50:40.578320Z 0 [Note] WSREP: Setting wsrep_ready to false
2017-12-18T07:50:40.578330Z 0 [Note] WSREP: No pre-stored wsrep-start position found. Skipping position initialization.
2017-12-18T07:50:40.578335Z 0 [Note] WSREP: wsrep_load(): loading provider library '/usr/lib64/galera3/libgalera_smm.so'
2017-12-18T07:50:40.582014Z 0 [Note] WSREP: wsrep_load(): Galera 3.22(r8678538) by Codership Oy
<info@codership.com> loaded successfully.
从上所示,当前的系统时间为mysql日志记录的时间不一致。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
二、系统变量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.
从上描述可知,这个变量是在MySQL 5.7.2中添加的。缺省值为UTC。
如果如要使用缺省时区的时间,修改该参数的值为SYSTEM
1
2
3
4
5
6
7
8
9
10
11
12
13
三、修改及验证
mysql> set global log_timestamps='SYSTEM';
Query OK, 0 rows affected (0.00 sec)
[root@ydq-mnt mysql]# vim /etc/percona-xtradb-cluster.conf.d/mysqld.cnf
log_timestamps=SYSTEM
[root@ydq-mnt ~]# systemctl restart mysql
2017-12-18T07:52:41.543983Z 0 [Note] Beginning of list of non-natively partitioned tables
2017-12-18T07:52:41.544128Z 0 [Note] WSREP: Member 0.0 (ydq-mnt) synced with group.
2017-12-18T07:52:41.544138Z 0 [Note] WSREP: Shifting JOINED -> SYNCED (TO: 4163)
2017-12-18T07:52:41.550738Z 8 [Note] WSREP: Synchronized with group, ready for connections
2017-12-18T07:52:41.550755Z 8 [Note] WSREP: This node is synced, setting wsrep_ready to true
2017-12-18T07:52:41.550761Z 8 [Note] WSREP: wsrep_notify_cmd is not defined, skipping notification.
2017-12-18T07:52:41.582207Z 0 [Note] End of list of non-natively partitioned tables
2017-12-18T07:52:43.178826Z 0 [Note] InnoDB: Buffer pool(s) load completed at 171218 15:52:43
2017-12-18T16:24:23.588881+08:00 0 [Note] WSREP: Received shutdown signal. Will sleep for 10 secs before initiating shutdown.
pxc_maint_mode switched to SHUTDOWN
2017-12-18T16:24:33.591354+08:00 0 [Note] WSREP: Stop replication
2017-12-18T16:24:33.591408+08:00 0 [Note] WSREP: Closing send monitor...
2017-12-18T16:24:33.591429+08:00 0 [Note] WSREP: Closed send monitor.
2017-12-18T16:24:33.591453+08:00 0 [Note] WSREP: gcomm: terminating thread
2017-12-18T16:24:33.591477+08:00 0 [Note] WSREP: gcomm: joining thread
2017-12-18T16:24:33.591700+08:00 0 [Note] WSREP: gcomm: closing backend
再次启动及验证,时间显示与系统时间一致。
---------------------
MySQL 5.7 时间显示修改(log_timestamps UTC)的更多相关文章
- jsp页面上读取MySQL数据库datetime时间显示问题
mysql数据库中时间字段选用了datetime,如果通过java实现在jsp页面上显示时间为"年-月-日 时:分"等格式,那么如下代码就会有不同的结果! 实体类中两个变量: p ...
- MySql的创建时间和修改时间
在创建时间字段的时候 DEFAULT CURRENT_TIMESTAMP表示当插入数据的时候,该字段默认值为当前时间 ON UPDATE CURRENT_TIMESTAMP表示每次更新这条数据的时 ...
- Centos修改时间显示的时区,将UTC修改为CST
问题说明: 今天一同事反应,系统的时间不对和正常的时间差8个小时.就登录主机看了下时间 系统时间显示为: # date Fri Dec :: UTC # 备注:查看了下,正好和当前的时间差了8个小时. ...
- Xiuno BBS 4.0 修改时间显示
修罗开源轻论坛程序 - Xiuno BBS 4.0Xiuno BBS 4.0 是一款轻论坛产品,前端基于 BootStrap 4.0.JQuery 3,后端基于 PHP/7 MySQL XCache/ ...
- Windows 修改个性化时间显示
A goal is a dream with a deadline. Much effort, much prosperity. 我感觉我的时间显示不够人性化.不够个性化 修改注册表 我的系统为Win ...
- MySQL 5.7贴心参数之 log_timestamps
写在前面 使用 MySQL 的过程中,经常会有人碰到这么一个问题,看错误日志.慢查询日志的时候,时间总是和本地时间对不上,差了 8 个小时,这样分析起来就相对麻烦了一些. 新改进 对于不知道是什么原因 ...
- MySQL5.7 error log时间显示问题
最近有两三套环境升级到了5.7.16,发现mysql.err中的时间好像有些问题,经查是mysql 5.7后的变更,如下: root@localhost [(none)]>select now( ...
- MySQL日期和时间类型笔记
最近在看<MySQL技术内幕:SQL编程>并做了笔记,这是一篇笔记类型博客,分享出来方便自己复习,也可以帮助其他人 一.日期时间类型所占空间对比 各种日期时间数据类型所占的空间: 类型 所 ...
- MySQL 获得当前日期时间\时间戳 函数 ( 转自传智播客)
MySQL 获得当前日期时间 函数 1.1 获得当前日期+时间(date + time)函数:now() mysql> select now(); +-------+ | now() | +-- ...
随机推荐
- Python模块简介及安装 [numpy,pandas,matplotlib,scipy,statsmodels,Gensim,sklearn,keras]
https://pan.baidu.com/s/1bpVv3Ef 67bd 模块安装文件下载地址 pip install "numpy-1.12.0b+mkl-cp35- ...
- 死磕!Windows下Apache+PHP+phpmyadmin的配置
环境配置真的很烦很费时间,稍不小心就会出错,这是一个鸡肋体力劳动,耐心和忍耐少不了.这个资料已经非常详细了,其中变量和路径不是百分百吻合但是意思已经很清楚了.剩下的就是耐心的执行和琢磨了. 一. A ...
- tomcat整体架构
1.背景 Tomcat作为JavaWeb领域的Web容器,目前在我们淘宝也使用的也非常广泛,现在基本上所有线上业务系统都是部署在Tomcat上.为了对平时开发的Web系统有更深入的理解以及出于好奇心对 ...
- ALGO-120_蓝桥杯_算法训练_学做菜
问题描述 涛涛立志要做新好青年,他最近在学做菜.由于技术还很生疏,他只会用鸡蛋,西红柿,鸡丁,辣酱这四种原料来做菜,我们给这四种原料标上字母A,B,C,D. 涛涛现在会做的菜有五种: . 西红柿炒鸡蛋 ...
- ALGO-139_蓝桥杯_算法训练_s01串(递归)
问题描述 s01串初始为" 按以下方式变换 0变1,1变01 输入格式 1个整数(~) 输出格式 n次变换后s01串 样例输入 样例输出 数据规模和约定 ~ 记: 题目给出的信息带有误导性, ...
- VB编程插件AmicForVB插件
VB编程插件AmicForVB插件下载地址http://www.vbgood.com/thread-32788-1-1.htmlhttp://www.vbgood.com/forum.php?mod= ...
- Windows下利用TortoiseSVN搭建本地SVN服务器
写在前面: 安装TortoiseSVN时,图中这步要选择,才能同时安装后面需要的svnserve.exe 环境说明: Win 7 TortoiseSVN 1.7 搭建步骤: 0. 新建一个目录,做&q ...
- ES6基础二(数组)
JSON数组格式转换 JSON的数组格式就是为了前端快速的把JSON转换成数组的一种格式:在普通的JSON最后多了一个length属性,就可以使用ES6的语法转变成数组. 当然了,不是所有的j ...
- 关于git中自己的分支和主分支有冲突的解决方案(git和乌龟git)
阐述一个案例,最近在开发中遇到一个问题.自己在代码的主分支拉了一个分支,开始快乐的开发修改了.同事小明也在主分支拉了一个分支,也在快乐的修改.小明的开发速度很快,一个问题很快就解决了,并且把自己的代码 ...
- android webview内存泄露解决方法
完整的activity的onDestroy()方法:@Override protected void onDestroy() { if( mWebView!=null) { // 如果先调用destr ...