centos:另一个 MySQL 守护进程已经使用相同的 unix 套接字运行
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20407292/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
centos: Another MySQL daemon already running with the same unix socket
提问by Mas
I have a strange error when starting mysqld service:
启动mysqld服务时出现奇怪的错误:
Another MySQL daemon already running with the same unix socket.
I've tried to list running services and stopping them but the same error happens when starting mysqld service.
我试图列出正在运行的服务并停止它们,但是在启动 mysqld 服务时发生了同样的错误。
I can try to remove the mysqld and reinstall it but will this remove the database too?
我可以尝试删除 mysqld 并重新安装它,但这也会删除数据库吗?
回答by GeckoSEO
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
# 关闭 -h 现在
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:
基于Centos,当你遇到这个问题时,另一个让它重新备份的方法是移动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
重新启动服务会创建一个名为 mqsql.sock 的新条目
回答by iconoclast
TL;DR:
特尔;博士:
Run this as root and you'll be all set:
以 root 身份运行它,你就可以了:
rm $(grep socket /etc/my.cnf | cut -d= -f2) && service mysqld start
Longer version:
更长的版本:
You can find the location of MySQL's socket file by manually poking around in /etc/my.conf
, or just by using
您可以通过手动在 中查找 MySQL 的套接字文件的位置/etc/my.conf
,或者仅使用
grep socket /etc/my.cnf | cut -d= -f2
It is likely to be /var/lib/mysql/mysql.sock
. Then (as root, of course, or with sudo
prepended) remove that file:
很可能是/var/lib/mysql/mysql.sock
。然后(当然,以 root 身份,或者在sudo
前面)删除该文件:
rm /var/lib/mysql/mysql.sock
Then start the MySQL daemon:
然后启动 MySQL 守护进程:
service mysqld start
Removing mysqld
will not address the problem at all. The problem is that CentOS & RedHat do not clean up the sock
file after a crash, so you have to do it yourself. Avoiding powering off your system is (of course) also advised, but sometimes you can't avoid it, so this procedure will solve the problem.
删除mysqld
根本无法解决问题。问题是 CentOS & RedHatsock
在崩溃后不会清理文件,所以你必须自己做。(当然)也建议避免关闭系统电源,但有时您无法避免,因此此过程将解决问题。
回答by Mas
I have found a solution for anyone in this problem change the socket dir to a new location in my.cnf file
我找到了解决此问题的任何人的解决方案将套接字目录更改为 my.cnf 文件中的新位置
socket=/var/lib/mysql/mysql2.sock
and service mysqld start
和 service mysqld start
or the fast way as GeckoSEO answered
或 GeckoSEO 回答的快速方法
# mv /var/lib/mysql/mysql.sock /var/lib/mysql/mysql.sock.bak
# service mysqld start
回答by user3076142
My solution to this was a left over mysql.sock in the /var/lib/mysql/ directory from a hard shutdown. Mysql thought it was already running when it was not running.
我对此的解决方案是硬关机时在 /var/lib/mysql/ 目录中遗留的 mysql.sock。mysql在没有运行的时候以为已经在运行了。
回答by Paul
Just open a bug report with your OS vendor asking them to put the socket in /var/run so it automagically gets removed at reboot. It's a bug to keep this socket after an unclean reboot, /var/run is the spot for these kinds of files.
只需向您的操作系统供应商打开错误报告,要求他们将套接字放在 /var/run 中,以便在重新启动时自动删除它。在不干净的重启后保留这个套接字是一个错误,/var/run 是这些文件的地方。
回答by Vikash Kumar
It may sometime arises when MySQL service does not shut down properly during the OS reboot. The /var/lib/mysql/mysql.sock has been left. This prevents 'mysqld' from starting up.
当操作系统重启期间 MySQL 服务没有正确关闭时,有时可能会出现这种情况。/var/lib/mysql/mysql.sock 已经离开了。这会阻止 'mysqld' 启动。
These steps may help:
这些步骤可能会有所帮助:
1: service mysqld start killall -9 mysqld_safe mysqld service mysqld start
1: service mysqld start killall -9 mysqld_safe mysqld service mysqld start
2: rm /var/lib/mysql/mysql.sock service mysqld start
2:rm /var/lib/mysql/mysql.sock服务mysqld启动
回答by ugo
in order to clean automatically .sock file, place these lines in file /etc/init.d/mysqld immediately after "start)" block of code
为了自动清理 .sock 文件,将这些行放在文件 /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 "NOT CLEAN"
rm -f /var/lib/mysql/mysql.sock
echo "FILE SOCK REMOVED"
else
echo "CLEAN"
fi
it worked for me. I had to do this because I have not an UPS and often we have power supply failures.
它对我有用。我不得不这样做,因为我没有 UPS,而且经常出现电源故障。
regards.
问候。
回答by Kamesh Jungi
To start the MySQL service, you can remove '/var/lib/mysql/mysql.sock' and start the MySQL service again:
要启动 MySQL 服务,您可以删除 '/var/lib/mysql/mysql.sock' 并再次启动 MySQL 服务:
Remove the socket file:
删除套接字文件:
[root@server ~]# rm /var/lib/mysql/mysql.sock
rm: remove socket `/var/lib/mysql/mysql.sock'? yes
Start the MySQL service:
启动 MySQL 服务:
[root@server~]# service mysqld start
Starting mysqld: [ OK ]
It will help you to resolve your problem.
它将帮助您解决您的问题。
回答by Balkrushna Patil
It's just happen because of abnormal termination of mysql service. delete or take backup of /var/lib/mysql/mysql.sock file and restart mysql.
这只是因为mysql服务异常终止而发生的。删除或备份 /var/lib/mysql/mysql.sock 文件并重新启动 mysql。
Please let me know if in case any issue..
如果有任何问题,请告诉我..
回答by webjawns.com
I just went through this issue and none of the suggestions solved my problem. While I was unable to start MySQL on boot and found the same message in the logs ("Another MySQL daemon already running with the same unix socket"), I was able to start the service once I arrived at the console.
我刚刚解决了这个问题,但没有任何建议解决了我的问题。虽然我无法在启动时启动 MySQL 并在日志中发现相同的消息(“另一个 MySQL 守护程序已经在使用相同的 unix 套接字运行”),但一旦我到达控制台,我就能够启动该服务。
In my configuration file, I found the following line: bind-address=xx.x.x.x
. I randomly decided to comment it out, and the error on boot disappeared. Because the bind address provides security, in a way, I decided to explore it further. I was using the machine's IP address, rather than the IPv4 loopback address - 127.0.0.1
.
在我的配置文件中,我发现了以下行:bind-address=xx.x.x.x
. 我随意决定将其注释掉,启动时的错误消失了。因为绑定地址在某种程度上提供了安全性,所以我决定进一步探索它。我使用的是机器的 IP 地址,而不是 IPv4 环回地址 - 127.0.0.1
。
In short, by using 127.0.0.1
as the bind-address
, I was able to fix this error. I hope this helps those who have this problem, but are unable to resolve it using the answers detailed above.
简而言之,通过使用127.0.0.1
as bind-address
,我能够修复此错误。我希望这可以帮助那些遇到此问题但无法使用上面详述的答案解决它的人。