如何解決MySQL慢查詢?nèi)罩緯r間與系統(tǒng)時間相差8小時?相信很多沒有經(jīng)驗的人對此束手無策,為此本文總結(jié)了問題出現(xiàn)的原因和解決方法,通過這篇文章希望你能解決這個問題。
創(chuàng)新互聯(lián)是一家專注于網(wǎng)站設計制作、成都網(wǎng)站建設與策劃設計,金灣網(wǎng)站建設哪家好?創(chuàng)新互聯(lián)做網(wǎng)站,專注于網(wǎng)站建設十年,網(wǎng)設計領域的專業(yè)建站公司;建站業(yè)務涵蓋:金灣等地區(qū)。金灣做網(wǎng)站價格咨詢:18980820575
在對慢查詢進行查看的時候發(fā)現(xiàn)時間不對,正好與系統(tǒng)時間相差8個小時。
1、慢查詢顯示時間如下
# Time: 2020-01-10T06:42:24.940811Z
2、系統(tǒng)時間
$ date
Fri Jan 10 14:42:31 CST 2020
3、查看數(shù)據(jù)庫參數(shù)
mysql> show variables like 'log_timestamps';
+----------------+-------+
| Variable_name | Value |
+----------------+-------+
| log_timestamps | UTC |
+----------------+-------+
1 row in set (0.00 sec)
UTC大家都知道是世界統(tǒng)一時間,而我現(xiàn)在的系統(tǒng)時間是東八區(qū),比UTC早了8個小時,這就對上了。查看官方文檔看一下官網(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ù)就可以解決問題。
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 |
+----------------+--------+
以上就是慢查詢?nèi)罩緯r間與系統(tǒng)不一致的解決方法,詳細使用情況還需要大家自己親自動手使用過才能領會。如果想了解更多相關內(nèi)容,歡迎關注創(chuàng)新互聯(lián)行業(yè)資訊頻道!
文章題目:MySQL慢查詢?nèi)罩緯r間與系統(tǒng)不一致的解決方法
新聞來源:http://jinyejixie.com/article36/poccpg.html
成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供全網(wǎng)營銷推廣、定制網(wǎng)站、網(wǎng)站設計公司、用戶體驗、企業(yè)建站、自適應網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)