且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

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

更新时间:2022-10-02 20:33:13

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


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


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

    

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

    

两个方法解决:

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

    第二个直接把mysql.sock文件改名即可。也可以删除,推荐改名。然后就可以启动mysql了


下面是国外原文


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


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


本文转自willis_sun 51CTO博客,原文链接:http://blog.51cto.com/willis/1865685,如需转载请自行联系原作者