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

How to solve the problem of inconsistency between mysql5.7 log time and system time

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

Share

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

This article mainly introduces "how to solve the problem of inconsistency between mysql5.7 log time and system time". In daily operation, it is believed that many people have doubts about how to solve the problem of inconsistency between mysql5.7 log time and system time. The editor consulted all kinds of materials and sorted out simple and useful operation methods. I hope it will be helpful to answer the question of "how to solve the problem of inconsistency between mysql5.7 log time and system time"! Next, please follow the editor to study!

The parameter log_timestamps is added in MySQL 5.7.2, which is mainly used to control the display time parameters of error log, genera log, and so on.

And the default post-installation error_log,slow_log log timestamp defaults to UTC, so it will be inconsistent with the system time, with a difference of 8 hours from Beijing time

[reference manual]

Log_timestamps

PropertyValueCommand-Line Format--log-timestamps=#Introduced5.7.2System Variablelog_timestampsScopeGlobalDynamicYesTypeenumerationDefault ValueUTCValid 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).

[view system settings]

SHOW GLOBAL VARIABLES LIKE 'log_timestamps'

+-+ +

| | Variable_name | Value |

+-+ +

| | log_timestamps | UTC |

+-+ +

Because log_timestamps is a global parameter of GLOBAL, set the global parameter directly after login, and it will expire directly after restart.

[processing method]

Step 1: SET GLOBAL log_timestamps = system; will take effect immediately

Because log_timestamps is a global parameter of GLOBAL, set the global parameter directly after login, and it will expire directly after restart. Therefore, you need to add a log_timestamps configuration to [mysqld] in the configuration file of mysql.

Step 2: log_timestamps=SYSTEM

At this point, the study on "how to solve the problem of inconsistency between mysql5.7 log time and system time" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

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

Database

Wechat

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

12
Report