Get the App
SLTechnology News&Howtos  ›  Database  › 

The solution to the incorrect time of Mysql5.7 error log

Shulou Source: shulou.com Published: 2022-06-01 06:24:49 10月03日 Update

The error log time of MySQL 5.7is inconsistent with the system time, which seems to be laborious. According to the official documents, log_timestamps parameter has been added since MySQL 5.7.2, which mainly controls the display time parameters of error log, genera log and other log files:

The official text is as follows:

This variable controls the timestamp time zone of error log messages, and of 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).

This variable was added in MySQL 5.7.2. Before 5.7.2, timestamps in log messages were written using the local system time zone by default, not UTC. If you want the previous log message time zone default, set log_timestamps=SYSTEM.

After making the following changes, the display is normal:

Click (here) to collapse or open

(root@localhost) [(none)] > show global variables like 'log_timestamps'

+-+ +

| | Variable_name | Value |

+-+ +

| | log_timestamps | UTC |

+-+ +

1 row in set (0.01 sec)

(root@localhost) [(none)] > set global log_timestamps=SYSTEM

Query OK, 0 rows affected (0.00 sec)

(root@localhost) [(none)] > SHOW global variables like 'log_timestamps'

+-+ +

| | Variable_name | Value |

+-+ +

| | log_timestamps | SYSTEM |

+-+ +

1 row in set (0.01 sec)

Tags: Time log parameter error effort consistency official file document system control wrong method Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Linux Xiaomi Microsoft MySQL