Get the App
SLTechnology News&Howtos  ›  Database  › 

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

Shulou Source: shulou.com Published: 2022-05-31 14:27:44 10月03日 Update

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!

Tags: Time parameters logs system consistency problems global learning methods more steps help login configuration utility next hours manuals files articles Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia Microsoft Linux MariaDB MySQL