Get the App
SLTechnology News&Howtos  ›  Database  › 

What is the reason for the 8-hour difference between MySQL5.7 slow query log time and system time?

Shulou Source: shulou.com Published: 2022-05-31 21:43:48 10月03日 Update

This article mainly shows you the "MySQL5.7 slow query log time and system time difference of 8 hours what is the reason", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn the "MySQL5.7 slow query log time and system time difference of 8 hours why" this article.

When checking the slow query, it is found that the time is wrong, which is exactly 8 hours different from the system time.

1. The display time of slow query is as follows

# Time: 2020-01-10T06:42:24.940811Z

2. System time

$dateFri Jan 10 14:42:31 CST 2020

3. View database parameters

Mysql > show variables like 'log_timestamps';+-+-+ | Variable_name | Value | +-+-+ | log_timestamps | UTC | +-+-+ 1 row in set (0.00 sec)

UTC everyone knows that it is the world unified time, but my current system time is East eighth District, which is 8 hours earlier than UTC, which is right. Check the official documentation and see the explanation on the official website.

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).

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).

The problem can be solved by modifying the parameters.

Mysql > SET GLOBAL log_timestamps = SYSTEM;Query OK, 0 rows affected (0.00 sec) mysql > SHOW GLOBAL VARIABLES LIKE 'log_timestamps' +-+-+ | Variable_name | Value | +-+-+ | log_timestamps | SYSTEM | +-+-+ all the contents of the article entitled "what is the reason for the 8-hour difference between MySQL5.7 slow query log time and system time"? Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Time system hour query reason log time difference content article parameter learning help no world official data database document time easy to understand Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology NVidia MariaDB MySQL Shulou Tech Info