怎么解决mysql5.7日志时间与系统时间不一致问题

这篇文章主要介绍“怎么解决MySQL5.7日志时间与系统时间不一致问题”,在日常操作中,相信很多人在怎么解决mysql5.7日志时间与系统时间不一致问题问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”怎么解决mysql5.7日志时间与系统时间不一致问题”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!

创新互联自2013年创立以来,是专业互联网技术服务公司,拥有项目网站制作、做网站网站策划,项目实施与项目整合能力。我们以让每一个梦想脱颖而出为使命,1280元泌阳做网站,已为上家服务,为泌阳各地企业和个人服务,联系电话:028-86922220

在MySQL 5.7.2 新增了 log_timestamps 这个参数,该参数主要是控制 error log、genera log,等等记录日志的显示时间参数

且默认安装后error_log,slow_log 日志时间戳默认为UTC,因此会造成与系统时间不一致,与北京时间相差8个小时;

【参考手册】

log_timestamps

Property Value
Command-Line Format --log-timestamps=#
Introduced 5.7.2
System Variable log_timestamps
Scope Global
Dynamic Yes
Type enumeration
Default Value UTC
Valid Values

UTC

SYSTEM

This variable controls the time zone of timestamps in messages written to the error log, and in 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). 

【查看系统设置】

SHOW GLOBAL VARIABLES LIKE 'log_timestamps';
+---------------------+-------------------+
|Variable_name  |              Value   |
+---------------------+-------------------+
|log_timestamps |              UTC     |
+---------------------+-------------------+

因为log_timestamps  是一个GLOBAL的全局参数,所以直接在登录后去set全局参数,重启后就会直接失效;

【处理方法】

步骤一:SET GLOBAL log_timestamps = system;  马上生效

因为log_timestamps  是一个GLOBAL的全局参数,所以直接在登录后去set全局参数,重启后就会直接失效;因此需要在mysql的配置文件中[mysqld]中增加一条log_timestamps的配置

步骤二:log_timestamps=SYSTEM;

到此,关于“怎么解决mysql5.7日志时间与系统时间不一致问题”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注创新互联网站,小编会继续努力为大家带来更多实用的文章!


网站标题:怎么解决mysql5.7日志时间与系统时间不一致问题
本文地址:http://lszwz.com/article/pgdhie.html

其他资讯

售后响应及时

7×24小时客服热线

数据备份

更安全、更高效、更稳定

价格公道精准

项目经理精准报价不弄虚作假

合作无风险

重合同讲信誉,无效全额退款