Unable to start MySQL service. Another MySQL daemon is already running with the same UNIX socket,unablemysql
Unable to start MySQL service. Another MySQL daemon is already running with the same UNIX socket
特徵
如果你遇到如下所列的任何問題之一,本文也許能幫到你.
- MySQL starts/stops properly when started/stopped with the mysqld service restart, but MySQL does not start when a server is rebooted.
- After upgrading MySQL, binaries mysqld will not start at all.
- After relocating the MySQL datadir or changing the default port, MySQL does not start.
以上所有問題有一個共同特徵:你無法使用service mysqld restart/start或其他方式啟動mysql.
| 1234 |
[root@server ~]# /etc/init.d/mysqld startAnother MySQL daemon already running with the same unix socket.Starting mysqld: [FAILED] |
原因
非正常的關閉/停止服務,導致mysqld的socket沒有被移除. 該非正常的方式比較常見於:系統斷電重啟.
解決辦法
There are several common cases when the socket file is not removed. Please check the below use cases and apply the appropriate resolution.
1. 查看/var/log/mysqld.log,你會發現類似如下日誌:
| 123456789 |
13120721:15:47mysqld_safeStartingmysqlddaemonwithdatabasesfrom/var/lib/mysql/usr/libexec/mysqld:Can't create/write to file '/tmp/ib0h0Wt3' (Errcode: 13)131207 21:15:47 InnoDB: Error: unable to create temporary file; errno: 13131207 21:15:47 [ERROR] Plugin 'InnoDB' init function returned error.131207 21:15:47 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.131207 21:15:47 [Note] Event Scheduler: Loaded 0 events131207 21:15:47 [Note] /usr/libexec/mysqld: ready for connections.Version: '5.1.71' socket: '/var/lib/mysql/mysql.sock' port:3306 Sourcedistribution |
網上百度到該問題的解決辦法都是:
| 1 |
rm /var/lib/mysql/mysql.sock |
| 1 |
<spanstyle="font-family: monospace;">mv/var/lib/mysql/mysql.sock/var/lib/mysql/mysql.sock.bak</span> |
筆者試了很多此,發現還是啟動不成功.細看log,文本末尾寫著的不只/var/lib/mysql/mysql.sock,還有/var/lib/mysql/mysql1.sock,/var/lib/mysql/mysql22.sock.而我的檔案夾目錄中也正好存在這些檔案.於是猜想, mysql異常關閉之後,不單只產生myql.sock,還有其他sock檔案,我將這三個sock檔案都重新命名後,myql便正常啟動了.
| 1 |
rm /var/lib/mysql/mysql.sock |
| 1 |
rm/var/lib/mysql/mysql1.sock |
| 1 |
rm/var/lib/mysql/mysql22.sock |
2. 總結
mysql異常關閉時,產生的sock檔案可能存在多個,要將這些sock檔案都清除,mysql才能正常啟動.
原文連結:Unable to start MySQL service. Another MySQL daemon is already running with the same UNIX socket.
參考文獻:http://kb.sp.parallels.com/en/119334