1. 程式人生 > >linux 系統中系統關機後,mysql啟動失敗報錯:ERROR 2002 (HY000): Can't connect to local MySQL server through socket '

linux 系統中系統關機後,mysql啟動失敗報錯:ERROR 2002 (HY000): Can't connect to local MySQL server through socket '

自己在阿里雲伺服器上安裝好執行環境後,mysql都是正常使用的,昨天強制關閉伺服器後,重新啟動伺服器,發現數據庫無法啟動報錯:ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111)

通過檢視mysqld.log(日誌路徑/var/log/)日誌如下:

180914 10:57:33 [Note] Plugin 'FEDERATED' is disabled. 180914 10:57:33 InnoDB: The InnoDB memory heap is disabled 180914 10:57:33 InnoDB: Mutexes and rw_locks use GCC atomic builtins 180914 10:57:33 InnoDB: Compressed tables use zlib 1.2.3 180914 10:57:33 InnoDB: Using Linux native AIO 180914 10:57:33 InnoDB: Initializing buffer pool, size = 128.0M 180914 10:57:33 InnoDB: Completed initialization of buffer pool 180914 10:57:33 InnoDB: highest supported file format is Barracuda. 180914 10:57:33  InnoDB: Waiting for the background threads to start 180914 10:57:34 InnoDB: 5.5.61 started; log sequence number 2129689 180914 10:57:34 [Note] Server hostname (bind-address): '0.0.0.0'; port: 3306 180914 10:57:34 [Note]   - '0.0.0.0' resolves to '0.0.0.0'; 180914 10:57:34 [Note] Server socket created on IP: '0.0.0.0'. 180914 10:57:34 [ERROR] Can't start server: can't check PID filepath: No such file or directory

最後網路搜尋解決方案是:

1、在以下目錄中(/run/)建立mysqld資料夾:mkdir /run/mysqld

2、給mysqld許可權:chown -R mysql:mysql /run/mysqld

3、執行啟動:/etc/init.d/mysqld start

service mysql status  啟動成功