MySQL错误Another MySQL daemon already running with the same unix socket.

    

        安装Cacti的过程当中配置了数据库,但因为是在虚拟机里作的,习惯性的关机直接是Force off硬关机,刚配置完的cacti在我非正常关机重起后出现了问题,问题以下:mysql


[root@server2 ~]# /etc/init.d/mysqld start
Another MySQL daemon already running with the same unix socket.
Starting mysqld:                                           [FAILED]
sql


重点在这一句:Another MySQL daemon already running with the same unix socket.数据库

    

    查阅了很多资料,终于找到了答案,缘由是,在mysql安装目录里有一个mysql.sock文件。这个文件在mysql启动时建立的,mysql关闭时删除。那若是是非正常关机,mysql就没有机会去删除之个文件。当这个文件还存在时,mysql就启动不了,提示上面的错误。socket

    

两个方法解决:ide

    第一个是当即关机 使用命令 shutdown -h now 关机,关机后在启动,进程就中止了。this

    第二个直接把mysql.sock文件更名便可。也能够删除,推荐更名。而后就能够启动mysql了spa


下面是国外原文
unix


To prevent the problem from occurring, you must perform a graceful shutdown of the server from the command line rather than powering off the server.

shutdown -h now
orm


This will stop the running services before powering down the machine.

Based on Centos, an additional method for getting it back up again when you run into this problem is to move mysql.sock:

# mv /var/lib/mysql/mysql.sock /var/lib/mysql/mysql.sock.bak

# service mysqld start

Restarting the service creates a new entry called mqsql.sock
server