MySQL5.7 parameter Log_timestamps

Source: Internet
Author: User
Tags iso 8601

recently tested MySQL 5.7.21  Community Server This version of the MySQL database, the time to find its error log is inconsistent with the current time of the system, the later check found that the date and time format is UTC time, check the relevant information, originally in MySQL 5.7.2 The timestamp in the log file is then changed from the default Local system time zone to the UTC format. MySQL 5.7.2 more than one parameter log_timestamps, this parameter is mainly to control the error log, slow query log, such as the display time in the log. However, it does not affect the display time of the query log and slow log writes to the table (Mysql.general_log, Mysql.slow_log). When querying records, you can use the Convert_tz () function or set the session-level system variable Time_zone to convert to the desired time zone. The official details are as follows:

 

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's general query log and slow query log messages written to tables (Mysql.general_log, Mys Ql.slow_log). Rows retrieved from those tables can is 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 is UTC (the default) and SYSTEM (local SYSTEM time zone).

Timestamps is 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 (a offset from UTC).

This variable is 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.

This parameter is global, can be modified dynamically, the value of modifying parameter log_timestamps is very simple, as shown below, but it is better to set this parameter value in the parameter file my.cnf in case the MySQL service restart fails.

 like ' Log_timestamps ';
+----------------+-------+
Value |
+----------------+-------+
| Log_timestamps | UTC |
+----------------+-------+
Row inch Set (0.01 sec)
Set Global Log_timestamps=system;
rows Affected (0.00 sec)
 like ' Log_timestamps ';
+----------------+--------+
Value |
+----------------+--------+
| Log_timestamps | SYSTEM |
+----------------+--------+
Row inch Set (0.01 sec)
Mysql>

Resources:

http://mysql.taobao.org/monthly/2017/01/09/

Https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_log_timestamps

MySQL5.7 parameter Log_timestamps

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.