标签:mysql daemon already running linux socket
Mysql服务器掉电之后发现网站链接数据库失败,查看数据集状态之后
[root@dbserver1~]# service mysqld status
mysqldis stopped
[root@dbserver1~]# chkconfig --list mysqld
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@dbserver1~]# service mysqld start
Another MySQLdaemon already running with the same unix socket
查看my.cnf中 socket文件位置
socket=/var/lib/mysql/mysql.sock
[root@dbserver1~]# ls -l /var/lib/mysql/mysql.sock
发现存在,猜测是断电之后mysql.sock没有被清除,遗留问题
在此次数据库启动时,发现mysql.sock存在,所以mysql启动失败
解决办法:
[root@dbserver1~]# mv /var/lib/mysql/mysql.sock /var/lib/mysql/mysql.sock.bak
[root@dbserver1~]# service mysqld start
Startingmysqld: [ OK ]
在其他服务器同样测试,断电之后,mysql可以正常启动
为了防止这种问题,可以在/etc/init.d/mysqld中的”start”之后添加如下代码
test -e /var/lib/mysql/mysql.sock SOCKEXIST=$? ps cax | grep mysqld_safe NOPIDMYSQL=$? echo NOPIDMYSQL $NOPIDMYSQL echo SOCKEXIST $SOCKEXIST if [ $NOPIDMYSQL -eq 1 ] && [ $SOCKEXIST -eq 0 ] ; then echo "NOTCLEAN" rm -f/var/lib/mysql/mysql.sock echo "FILE SOCKREMOVED" else echo"CLEAN" fi
本文出自 “相守姑娘说” 博客,请务必保留此出处http://sugarlovecxq.blog.51cto.com/6707742/1679996
Another MySQL daemon already running with the same unix socket
标签:mysql daemon already running linux socket
原文地址:http://sugarlovecxq.blog.51cto.com/6707742/1679996