在對(duì)慢查詢(xún)進(jìn)行查看的時(shí)候發(fā)現(xiàn)時(shí)間不對(duì),正好與系統(tǒng)時(shí)間相差8個(gè)小時(shí)。
1、慢查詢(xún)顯示時(shí)間如下
# Time: 2020-01-10T06:42:24.940811Z
2、系統(tǒng)時(shí)間
$ date
Fri Jan 10 14:42:31 CST 2020
3、查看數(shù)據(jù)庫(kù)參數(shù)
mysql> show variables like 'log_timestamps';
+----------------+-------+
| Variable_name | Value |
+----------------+-------+
| log_timestamps | UTC |
+----------------+-------+
1 row in set (0.00 sec)
UTC大家都知道是世界統(tǒng)一時(shí)間,而我現(xiàn)在的系統(tǒng)時(shí)間是東八區(qū),比UTC早了8個(gè)小時(shí),這就對(duì)上了。查看官方文檔看一下官網(wǎng)的解釋。
log_timestamps
Property Value
Command-Line Format --log-timestamps=#
Introduced 5.7.2
System Variable log_timestamps
Scope Global
Dynamic Yes
Type Enumeration
Default Value UTC
Valid 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).
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).
修改參數(shù)就可以解決問(wèn)題。
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 |
+----------------+--------+
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
您可能感興趣的文章:- MySQL慢查詢(xún)的坑
- MYSQL慢查詢(xún)和日志實(shí)例講解
- MySQL慢查詢(xún)?nèi)罩镜淖饔煤烷_(kāi)啟
- MYSQL慢查詢(xún)與日志的設(shè)置與測(cè)試
- MySQL 慢查詢(xún)?nèi)罩镜拈_(kāi)啟與配置
- 實(shí)例講解MySQL 慢查詢(xún)
- Mysql sql慢查詢(xún)監(jiān)控腳本代碼實(shí)例
- MySQL慢查詢(xún)?nèi)绾味ㄎ辉斀?/li>
- MySQL開(kāi)啟慢查詢(xún)方法及實(shí)例
- Mysql慢查詢(xún)優(yōu)化方法及優(yōu)化原則
- 通過(guò)MySQL慢查詢(xún)優(yōu)化MySQL性能的方法講解
- MySQL Threads_running飆升與慢查詢(xún)的相關(guān)問(wèn)題解決