https://www.jianshu.com/p/2120e38d91db
查询error.log,显示时间为凌晨1点左右
![](http://upload-images.jianshu.io/upload_images/9289816-3b6e78f92a6e5413.png?imageMogr2/auto-orient/strip|imageView2/2/w/416/format/webp)
查询系统时间正常
![](http://upload-images.jianshu.io/upload_images/9289816-4edbefcec2a27e1a.png?imageMogr2/auto-orient/strip|imageView2/2/w/270/format/webp)
查询数据库内时间正常
![](http://upload-images.jianshu.io/upload_images/9289816-b7184c23379197f1.png?imageMogr2/auto-orient/strip|imageView2/2/w/317/format/webp)
查询日志时间戳,发现该设置为UTC
show global variables like 'log_timestamps';
![](http://upload-images.jianshu.io/upload_images/9289816-23094fc23edc2ed9.png?imageMogr2/auto-orient/strip|imageView2/2/w/596/format/webp)
将其修改为系统时间
set global log_timestamps='SYSTEM';
![](http://upload-images.jianshu.io/upload_images/9289816-0807a626ee36bc1d.png?imageMogr2/auto-orient/strip|imageView2/2/w/494/format/webp)
![](http://upload-images.jianshu.io/upload_images/9289816-56f36fdb612fa9ae.png?imageMogr2/auto-orient/strip|imageView2/2/w/573/format/webp)
执行操作,查看error.log的变化发现已经生效
![](http://upload-images.jianshu.io/upload_images/9289816-d7adb19f4f44202e.png?imageMogr2/auto-orient/strip|imageView2/2/w/409/format/webp)
作者:飞翔的Tallgeese
链接:https://www.jianshu.com/p/2120e38d91db
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
https://blog.csdn.net/hyy_217/article/details/72781614
因为log_timestamps 是一个GLOBAL的全局参数,所以直接在登录后去set全局参数,重启后就会直接失效
因此需要在mysql的配置文件my.cnf中[mysqld]中增加一条log_timestamps的配置
log_timestamps=SYSTEM