一部Linux伺服器重新開機之後發現MySQL無法啟動,輸入
~% mysql
提示: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'
用指令檢視SQL服務 /etc/rc.d/init.d/mysqld status
提示:~% /etc/rc.d/init.d/mysqld status
mysqld is stopped
嘗試啟動服務:
/opt/lampp/bin/mysql.server start
Starting MySQL. ERROR! The server quit without updating PID file (/opt/lampp/var/mysql
然後我嘗試将my.cnf更名,重新開機mysql服務,以為會重新生成一個my.cnf檔案,卻發現mysql還是無法啟動。然後檢查發現檔案/var/lib/mysql/mysql.sock不存在,搜尋了整個硬碟都沒發現。重新開機系統也無效。
用指令查詢SQL log:sudo cat /var/log/mysqld.log
提示:
Can't start server: Bind on TCP/IP port: Address already in use.
Do you already have another mysqld server running on port: 3306 ?
Google後用這個方法解決:
指令:mysqld_safe & 成功啟動mysql服務
然後登陸:mysql –u root
本文轉simmy51CTO部落格,原文連結:http://blog.51cto.com/helpdesk/759405,如需轉載請自行聯系原作者