怎么解決mysql5.7日志時(shí)間與系統(tǒng)時(shí)間不一致問題

這篇文章主要介紹“怎么解決MySQL5.7日志時(shí)間與系統(tǒng)時(shí)間不一致問題”,在日常操作中,相信很多人在怎么解決mysql5.7日志時(shí)間與系統(tǒng)時(shí)間不一致問題問題上存在疑惑,小編查閱了各式資料,整理出簡(jiǎn)單好用的操作方法,希望對(duì)大家解答”怎么解決mysql5.7日志時(shí)間與系統(tǒng)時(shí)間不一致問題”的疑惑有所幫助!接下來,請(qǐng)跟著小編一起來學(xué)習(xí)吧!

創(chuàng)新互聯(lián)自2013年創(chuàng)立以來,是專業(yè)互聯(lián)網(wǎng)技術(shù)服務(wù)公司,擁有項(xiàng)目網(wǎng)站制作、做網(wǎng)站網(wǎng)站策劃,項(xiàng)目實(shí)施與項(xiàng)目整合能力。我們以讓每一個(gè)夢(mèng)想脫穎而出為使命,1280元泌陽做網(wǎng)站,已為上家服務(wù),為泌陽各地企業(yè)和個(gè)人服務(wù),聯(lián)系電話:028-86922220

在MySQL 5.7.2 新增了 log_timestamps 這個(gè)參數(shù),該參數(shù)主要是控制 error log、genera log,等等記錄日志的顯示時(shí)間參數(shù)

且默認(rèn)安裝后error_log,slow_log 日志時(shí)間戳默認(rèn)為UTC,因此會(huì)造成與系統(tǒng)時(shí)間不一致,與北京時(shí)間相差8個(gè)小時(shí);

【參考手冊(cè)】

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). 

【查看系統(tǒng)設(shè)置】

SHOW GLOBAL VARIABLES LIKE 'log_timestamps';
+---------------------+-------------------+
|Variable_name  |              Value   |
+---------------------+-------------------+
|log_timestamps |              UTC     |
+---------------------+-------------------+

因?yàn)閘og_timestamps  是一個(gè)GLOBAL的全局參數(shù),所以直接在登錄后去set全局參數(shù),重啟后就會(huì)直接失效;

【處理方法】

步驟一:SET GLOBAL log_timestamps = system;  馬上生效

因?yàn)閘og_timestamps  是一個(gè)GLOBAL的全局參數(shù),所以直接在登錄后去set全局參數(shù),重啟后就會(huì)直接失效;因此需要在mysql的配置文件中[mysqld]中增加一條log_timestamps的配置

步驟二:log_timestamps=SYSTEM;

到此,關(guān)于“怎么解決mysql5.7日志時(shí)間與系統(tǒng)時(shí)間不一致問題”的學(xué)習(xí)就結(jié)束了,希望能夠解決大家的疑惑。理論與實(shí)踐的搭配能更好的幫助大家學(xué)習(xí),快去試試吧!若想繼續(xù)學(xué)習(xí)更多相關(guān)知識(shí),請(qǐng)繼續(xù)關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編會(huì)繼續(xù)努力為大家?guī)砀鄬?shí)用的文章!

分享標(biāo)題:怎么解決mysql5.7日志時(shí)間與系統(tǒng)時(shí)間不一致問題
分享地址:http://www.muchs.cn/article4/pgdhie.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供外貿(mào)建站移動(dòng)網(wǎng)站建設(shè)、域名注冊(cè)、Google做網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

h5響應(yīng)式網(wǎng)站建設(shè)