Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

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

2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report