記一次mysql啟動(dòng)錯(cuò)誤:ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mys...

今天啟動(dòng)mysql的時(shí)候報(bào)了錯(cuò)ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'
運(yùn)行

systemctl status mysql.service

發(fā)現(xiàn)報(bào)錯(cuò)


image.png

查看具體錯(cuò)誤日志/var/mysql/error.log

2020-09-23T08:40:40.110099Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2020-09-23T08:40:40.110101Z 0 [Note] InnoDB: Uses event mutexes
2020-09-23T08:40:40.110103Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2020-09-23T08:40:40.110105Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2020-09-23T08:40:40.110109Z 0 [Note] InnoDB: Using Linux native AIO
2020-09-23T08:40:40.110789Z 0 [Note] InnoDB: Number of pools: 1
2020-09-23T08:40:40.214397Z 0 [Note] InnoDB: Using CPU crc32 instructions
2020-09-23T08:40:40.273755Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2020-09-23T08:40:40.438964Z 0 [Note] InnoDB: Completed initialization of buffer pool
2020-09-23T08:40:40.624783Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2020-09-23T08:40:41.001504Z 0 [ERROR] InnoDB: Database page corruption on disk or a failed file read of page [page id: space=0, page number=5]. You may have to recover from a backup.
2020-09-23T08:40:41.001519Z 0 [Note] InnoDB: Page dump in ascii and hex (16384 bytes):

問題原因總結(jié):

因?yàn)閿?shù)據(jù)庫(kù)中存在表損壞,進(jìn)而導(dǎo)致數(shù)據(jù)訪問錯(cuò)誤,導(dǎo)致mysql啟動(dòng)失??;mysql中check table 發(fā)現(xiàn)表有損壞,但表是innodb類型無法修復(fù)

解決:

在MySQL的配置文件/etc/mysql/mysql.conf.d/mysqld.cnf中加入

innodb_force_recovery=1

強(qiáng)制recovery,重啟mysql可以啟動(dòng)成功

sudo service mysql restart
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

友情鏈接更多精彩內(nèi)容