MySQL報(bào)錯(cuò):The?server?quit?without?updating?PID?file的解決思路與方法
今天在學(xué)習(xí)mysql 二進(jìn)制日志的時(shí)候需要在編輯my.cnf的文件,產(chǎn)生的一系列報(bào)錯(cuò),個(gè)人的排錯(cuò)思路和方法,僅供參考。
重啟damon、重啟mysql 發(fā)現(xiàn)報(bào)錯(cuò)
Starting MySQL. ERROR! The server quit without updating PID file (/usr/local/mysql/data/mysqld.pid).
發(fā)現(xiàn)注釋這三行配置之后發(fā)現(xiàn)可以正常啟動(dòng),那么問題就出現(xiàn)在這三行代碼上
log-bin = mysql-bin?? #binlog_expire_logs_seconds = 600 #max_binlog_size = 200M
查詢?nèi)罩景l(fā)現(xiàn)報(bào)錯(cuò):You have enabled the binary log, but you haven't provided the mandatory server-id. Please refer to the proper server start-up parameters documentation#您已經(jīng)啟用了二進(jìn)制日志,但是沒有提供必需的服務(wù)器id。請(qǐng)參考適當(dāng)?shù)姆?wù)器啟動(dòng)參數(shù)文檔
經(jīng)過百度發(fā)現(xiàn):MySQL 5.7.3以后版本必須配置server-id,否則無法啟用MySQL二進(jìn)制日志
嘗試啟動(dòng) 在my.cnf中添加 server-id = 1 唯一的服務(wù)辨識(shí)號(hào),數(shù)值位于 1 到 2^32-1之間。此值在master和slave上都需要設(shè)置。
如果 “master-host” 沒有被設(shè)置,則默認(rèn)為1, 但是如果忽略此選項(xiàng),MySQL不會(huì)作為master生效
添加參數(shù),并嘗試啟動(dòng)。
發(fā)現(xiàn)又報(bào)錯(cuò):Can't connect to local MySQL server through socket '/tmp/mysql.sock'
mysql的連接方式有兩種:一種是TCP/IP、一種是socket連接
mysql.sock的作用是程序與mysqlserver處于同一臺(tái)機(jī)器,發(fā)起本地連接時(shí)可用。
連接localhost通常通過一個(gè)Unix域套接字文件進(jìn)行,一般是/tmp/mysql.sock。
如果套接字文件被刪除了,本地客戶就不能連接。/tmp 文件夾屬于臨時(shí)文件,隨時(shí)可能被刪除。
每次mysql 啟動(dòng)的時(shí)候,都會(huì)生成一個(gè)mysql.sock 的文件,
socket = /var/lib/mysql/mysql.sock 建議將sock文件移動(dòng)至下var/lib/mysql/
嘗試重新啟動(dòng) 發(fā)現(xiàn)還是報(bào)錯(cuò) Starting MySQL. ERROR! The server quit without updating PID file
排錯(cuò):
1. 檢查目錄權(quán)限
2. selinux是否關(guān)閉
3. 檢查my.cnf參數(shù) port,datadir,basedir,socket 是否配置正常
排錯(cuò)發(fā)現(xiàn)是我配置sock目錄時(shí)候,并沒有給予權(quán)限
chown -R mysql:mysql /var/lib/mysql/ #設(shè)置權(quán)限,并查看 ls -alh | grep mysql drwxr-xr-x. 2 mysql mysql 6 Sep 14 16:19 mysql
再次嘗試啟動(dòng)mysql 發(fā)現(xiàn)還是報(bào)錯(cuò):Starting MySQL. ERROR! The server quit without updating PID file (/usr/local/mysql/data/mysqld.pid).
1. tail -f /usr/local/mysql/data/mysql.err /查詢MySQL自帶的日志文件mysql.err
#發(fā)現(xiàn)沒有關(guān)鍵錯(cuò)誤信息
2. tail /var/log/messages #記錄了絕大多數(shù)的系統(tǒng)日志
2022-09-15T06:32:03.776090Z 0 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
2022-09-15T06:32:03.776188Z 0 [Note] /usr/local/mysql/bin/mysqld (mysqld 5.7.33-log) starting as process 57901 ...
2022-09-15T06:32:03.780168Z 0 [Note] InnoDB: PUNCH HOLE support available
2022-09-15T06:32:03.780229Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2022-09-15T06:32:03.780253Z 0 [Note] InnoDB: Uses event mutexes
2022-09-15T06:32:03.780278Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2022-09-15T06:32:03.780411Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2022-09-15T06:32:03.780419Z 0 [Note] InnoDB: Using Linux native AIO
2022-09-15T06:32:03.780605Z 0 [Note] InnoDB: Number of pools: 1
2022-09-15T06:32:03.780695Z 0 [Note] InnoDB: Using CPU crc32 instructions
2022-09-15T06:32:03.781783Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2022-09-15T06:32:03.787253Z 0 [Note] InnoDB: Completed initialization of buffer pool
2022-09-15T06:32:03.789167Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2022-09-15T06:32:03.800452Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2022-09-15T06:32:03.805695Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2022-09-15T06:32:03.805865Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2022-09-15T06:32:03.819123Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2022-09-15T06:32:03.820045Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2022-09-15T06:32:03.820088Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2022-09-15T06:32:03.821153Z 0 [Note] InnoDB: Waiting for purge to start
2022-09-15T06:32:03.872143Z 0 [Note] InnoDB: 5.7.33 started; log sequence number 2980979
2022-09-15T06:32:03.872679Z 0 [Note] InnoDB: Loading buffer pool(s) from /usr/local/mysql/data/ib_buffer_pool
2022-09-15T06:32:03.872896Z 0 [Note] Plugin 'FEDERATED' is disabled.
2022-09-15T06:32:03.873741Z 0 [Note] InnoDB: Buffer pool(s) load completed at 220915 14:32:03
2022-09-15T06:32:03.875555Z 0 [ERROR] unknown variable 'binlog_expire_logs_seconds=600'
2022-09-15T06:32:03.875596Z 0 [ERROR] Aborting2022-09-15T06:32:03.875610Z 0 [Note] Binlog end
2022-09-15T06:32:03.875666Z 0 [Note] Shutting down plugin 'ngram'
2022-09-15T06:32:03.875678Z 0 [Note] Shutting down plugin 'partition'
2022-09-15T06:32:03.875681Z 0 [Note] Shutting down plugin 'BLACKHOLE'
2022-09-15T06:32:03.875684Z 0 [Note] Shutting down plugin 'ARCHIVE'
2022-09-15T06:32:03.875687Z 0 [Note] Shutting down plugin 'PERFORMANCE_SCHEMA'
2022-09-15T06:32:03.875727Z 0 [Note] Shutting down plugin 'MRG_MYISAM'
2022-09-15T06:32:03.875730Z 0 [Note] Shutting down plugin 'MyISAM'
2022-09-15T06:32:03.875738Z 0 [Note] Shutting down plugin 'INNODB_SYS_VIRTUAL'
2022-09-15T06:32:03.875741Z 0 [Note] Shutting down plugin 'INNODB_SYS_DATAFILES'
2022-09-15T06:32:03.875742Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLESPACES'
2022-09-15T06:32:03.875744Z 0 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN_COLS'
2022-09-15T06:32:03.875745Z 0 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN'
2022-09-15T06:32:03.875746Z 0 [Note] Shutting down plugin 'INNODB_SYS_FIELDS'
2022-09-15T06:32:03.875748Z 0 [Note] Shutting down plugin 'INNODB_SYS_COLUMNS'
2022-09-15T06:32:03.875749Z 0 [Note] Shutting down plugin 'INNODB_SYS_INDEXES'
2022-09-15T06:32:03.875751Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLESTATS'
2022-09-15T06:32:03.875752Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLES'
2022-09-15T06:32:03.875754Z 0 [Note] Shutting down plugin 'INNODB_FT_INDEX_TABLE'
2022-09-15T06:32:03.875755Z 0 [Note] Shutting down plugin 'INNODB_FT_INDEX_CACHE'
2022-09-15T06:32:03.875757Z 0 [Note] Shutting down plugin 'INNODB_FT_CONFIG'
2022-09-15T06:32:03.875758Z 0 [Note] Shutting down plugin 'INNODB_FT_BEING_DELETED'
2022-09-15T06:32:03.875760Z 0 [Note] Shutting down plugin 'INNODB_FT_DELETED'
2022-09-15T06:32:03.875761Z 0 [Note] Shutting down plugin 'INNODB_FT_DEFAULT_STOPWORD'
2022-09-15T06:32:03.875763Z 0 [Note] Shutting down plugin 'INNODB_METRICS'
2022-09-15T06:32:03.875764Z 0 [Note] Shutting down plugin 'INNODB_TEMP_TABLE_INFO'
2022-09-15T06:32:03.875766Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_POOL_STATS'
2022-09-15T06:32:03.875767Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE_LRU'
2022-09-15T06:32:03.875769Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE'
2022-09-15T06:32:03.875770Z 0 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX_RESET'
2022-09-15T06:32:03.875772Z 0 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX'
2022-09-15T06:32:03.875773Z 0 [Note] Shutting down plugin 'INNODB_CMPMEM_RESET'
2022-09-15T06:32:03.875775Z 0 [Note] Shutting down plugin 'INNODB_CMPMEM'
2022-09-15T06:32:03.875777Z 0 [Note] Shutting down plugin 'INNODB_CMP_RESET'
2022-09-15T06:32:03.875778Z 0 [Note] Shutting down plugin 'INNODB_CMP'
2022-09-15T06:32:03.875780Z 0 [Note] Shutting down plugin 'INNODB_LOCK_WAITS'
2022-09-15T06:32:03.875781Z 0 [Note] Shutting down plugin 'INNODB_LOCKS'
2022-09-15T06:32:03.875782Z 0 [Note] Shutting down plugin 'INNODB_TRX'
2022-09-15T06:32:03.875784Z 0 [Note] Shutting down plugin 'InnoDB'
2022-09-15T06:32:03.875854Z 0 [Note] InnoDB: FTS optimize thread exiting.
2022-09-15T06:32:03.876196Z 0 [Note] InnoDB: Starting shutdown...
2022-09-15T06:32:03.976840Z 0 [Note] InnoDB: Dumping buffer pool(s) to /usr/local/mysql/data/ib_buffer_pool
2022-09-15T06:32:03.977146Z 0 [Note] InnoDB: Buffer pool(s) dump completed at 220915 14:32:03
2022-09-15T06:32:05.488923Z 0 [Note] InnoDB: Shutdown completed; log sequence number 2980998
2022-09-15T06:32:05.490187Z 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
2022-09-15T06:32:05.490231Z 0 [Note] Shutting down plugin 'MEMORY'
2022-09-15T06:32:05.490243Z 0 [Note] Shutting down plugin 'CSV'
2022-09-15T06:32:05.490246Z 0 [Note] Shutting down plugin 'sha256_password'
2022-09-15T06:32:05.490248Z 0 [Note] Shutting down plugin 'mysql_native_password'
2022-09-15T06:32:05.490337Z 0 [Note] Shutting down plugin 'binlog'
2022-09-15T06:32:05.490478Z 0 [Note] /usr/local/mysql/bin/mysqld: Shutdown complete
發(fā)現(xiàn)關(guān)鍵字 unknown variable 未知的變量 binlog_expire_logs_seconds
我照著視頻里面的單詞一個(gè)個(gè)敲,不是我敲錯(cuò)。嘗試尋找度娘
在mysql 8.0版本中新增了binlog_expire_logs_seconds,該參數(shù)表示binlog的失效日期單位秒。
8.0之前的版本,binlog的失效日志用expire_logs_days來配置,單位是天。
參考鏈接:mysql 8 新特性之binlog_expire_logs_seconds
因?yàn)槲沂菍W(xué)習(xí)了8.0和5.7版本的Mysql都有在學(xué)習(xí),win端使用的是8.0 linux安裝的是5.7
所以是我mysql版本的問題導(dǎo)致。更改參數(shù)
[mysqld] user = mysql port = 3306 basedir = /usr/local/mysql # 創(chuàng)建目錄 datadir = /usr/local/mysql/data # 數(shù)據(jù)庫目錄 pid-file = /usr/local/mysql/data/mysqld.pid # mysql進(jìn)程 log-error = /usr/local/mysql/data/mysql.err # 錯(cuò)誤日志 socket = /var/lib/mysql/mysql.sock # 可以socket文件方式登錄mysql log-bin = /usr/local/mysql/data/bin-log/mysql-bin.log server-id = 1 #binlog_expire_logs_seconds = 600 max_binlog_size = 200M #Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links = 0 #禁止符號(hào)鏈接以防各種安全風(fēng)險(xiǎn) # Settings user and group are ignored when systemd is used. # If you need to run mysqld under a different user or group, # customize your systemd unit file for mariadb according to the # instructions in http://fedoraproject.org/wiki/Systemd # [mysqld_safe] # # include all files from the config directory # !includedir /etc/my.cnf.d explicit_defaults_for_timestamp=true
再再再再次嘗試啟動(dòng)MySQL
[root@master lib]# ps -aux | grep mysql root 53523 0.0 0.0 108096 620 pts/1 S+ 14:00 0:00 tail -f /usr/local/mysql/data/mysql.err root 54867 0.0 0.0 11820 1612 pts/0 S 14:05 0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/usr/local/mysql/data --pid-file=/usr/local/mysql/data/mysqld.pid mysql 55106 1.1 2.2 1145048 176116 pts/0 Sl 14:05 0:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/usr/local/mysql/data/mysql.err --pid-file=/usr/local/mysql/data/mysqld.pid --socket=/var/lib/mysql/mysql.sock --port=3306 root 55162 0.0 0.0 112816 976 pts/0 S+ 14:05 0:00 grep --color=auto mysql [root@master lib]# netstat -anptu | grep :3306 tcp6 0 0 :::3306 :::* LISTEN 55106/mysqld
嘗試登錄MySQL 發(fā)現(xiàn)又報(bào)錯(cuò):錯(cuò)誤2002 (HY000):無法通過套接字'/tmp/ MySQL連接到本地MySQL服務(wù)器
[root@master lib]# mysql -u root -p
Enter password:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock #設(shè)置軟連接
mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | atguigudb | | #mysql50#bin-log | | mysql | | performance_schema | | sys | | test | | test_u | +--------------------+ 8 rows in set (0.00 sec)
登錄成功?。?! 繼續(xù)繼續(xù)MySQL?。。_
總結(jié)
到此這篇關(guān)于MySQL報(bào)錯(cuò):The server quit without updating PID file的解決思路與方法的文章就介紹到這了,更多相關(guān)MySQL報(bào)錯(cuò)The server quit without updating PID file內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Linux系統(tǒng)利用crontab定時(shí)備份Mysql數(shù)據(jù)庫方法
本文教你如果快速利用系統(tǒng)crontab來定時(shí)執(zhí)行備份文件,按日期對(duì)備份結(jié)果進(jìn)行保存2021-09-09淺談MySQL中授權(quán)(grant)和撤銷授權(quán)(revoke)用法詳解
下面小編就為大家?guī)硪黄獪\談MySQL中授權(quán)(grant)和撤銷授權(quán)(revoke)用法詳解。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2016-09-09MySQL 1130異常,無法遠(yuǎn)程登錄解決方案詳解
這篇文章主要介紹了MySQL 1130異常,無法遠(yuǎn)程登錄解決方案詳解,本篇文章通過簡(jiǎn)要的案例,講解了該項(xiàng)技術(shù)的了解與使用,以下就是詳細(xì)內(nèi)容,需要的朋友可以參考下2021-08-08mysql8.0.20安裝與連接navicat的方法及注意事項(xiàng)
這篇文章主要介紹了mysql8.0.20安裝與連接navicat的方法及注意事項(xiàng),本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-05-05Mysql5.7中使用group concat函數(shù)數(shù)據(jù)被截?cái)嗟膯栴}完美解決方法
前幾天在項(xiàng)目中遇到一個(gè)問題,使用 GROUP_CONCAT 函數(shù)select出來的數(shù)據(jù)被截?cái)嗔?,最長(zhǎng)長(zhǎng)度不超過1024字節(jié),開始還以為是navicat客戶端自身對(duì)字段長(zhǎng)度做了限制的問題。后來查找出原因,解決方法大家跟隨腳本之家小編一起看看吧2018-03-03mysql判斷當(dāng)前時(shí)間是否在開始與結(jié)束時(shí)間之間且開始與結(jié)束時(shí)間允許為空
這篇文章主要介紹了mysql判斷當(dāng)前時(shí)間是否在開始與結(jié)束時(shí)間之間且開始與結(jié)束時(shí)間允許為空,文中通過示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2021-09-09MySQL中IF()、IFNULL()、NULLIF()、ISNULL()函數(shù)的使用詳解
在MySQL中可以使用IF()、IFNULL()、NULLIF()、ISNULL()函數(shù)進(jìn)行流程的控制。本文就詳細(xì)的介紹這幾種方法,感興趣的可以了解一下2021-06-06mysql8.0及以上my.cnf設(shè)置lower_case_table_names=1無法啟動(dòng)問題
這篇文章主要介紹了mysql8.0及以上my.cnf設(shè)置lower_case_table_names=1無法啟動(dòng)問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-11-11MySQL數(shù)據(jù)存儲(chǔ)路徑修改的超詳細(xì)教程
在生產(chǎn)環(huán)境下,mysql的數(shù)據(jù)、索引都會(huì)很大,而mysql的默認(rèn)存儲(chǔ)路徑是/val/lib/mysql,這就出現(xiàn)了問題,下面這篇文章主要給大家介紹了關(guān)于MySQL數(shù)據(jù)存儲(chǔ)路徑修改的超詳細(xì)教程,需要的朋友可以參考下2023-03-03