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

The solution to the inconsistency between MySQL slow query log time and system

2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

How to solve the difference of 8 hours between MySQL slow query log time and system time? I believe that many inexperienced people are at a loss about this, so this article summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.

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.940811Z2, system time $dateFri Jan 10 14:42:31 CST 20203, 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. Eight hours earlier than UTC, that's a good match. Check the official documentation and see the explanation on the official website. Log_timestampsProperty ValueCommand-Line Format-log-timestamps=#Introduced 5.7.2System Variable log_timestampsScope GlobalDynamic YesType EnumerationDefault Value UTCValid Values UTCSYSTEMThis 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 | +-+-+

The above is the solution to the inconsistency between the slow query log time and the system, and the detailed use needs to be used by everyone themselves in order to understand. If you want to know more about it, 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