MySQL. Time mismatch in error logs and slow queries logs

Once I turned on the logs of slow queries and noticed that the time is being written with the wrong time zone.

I connected to MySQL server:

mysql -u root -p

Looked at the value of log_timestamps (I had UTC, which is the default):

select @@global.time_zone;
show variables like "log_timestamps%";

I checked the timestamp value with the current time (it lagged because the system had a UTC+3 time zone):

show variables like "timestamp%";
select NOW();

Therefore, in order to display time with the time zone in the error logs and the slow query logs the same as in the system, change log_timestamps from UTC to SYSTEM:

SET GLOBAL log_timestamps='SYSTEM';

And also do not forget to indicate in the configuration file that it will not be reset after restarting the MySQL server:

log_timestamps = 'SYSTEM'

See also my article:
How to enable Slow Query Log in MySQL

Leave a comment

Leave a Reply