I have a strange error when starting mysqld service:
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.
I can try to remove the mysqld and reinstall it but will this remove the database too?
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
Run this as root and you'll be all set:
rm $(grep socket /etc/my.cnf | cut -d= -f2) && service mysqld start
You can find the location of MySQL's socket file by manually poking around in /etc/my.conf
, or just by using
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:
rm /var/lib/mysql/mysql.sock
Then start the MySQL daemon:
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.
I have found a solution for anyone in this problem change the socket dir to a new location in my.cnf file
socket=/var/lib/mysql/mysql2.sock
and service mysqld start
or the fast way as GeckoSEO answered
# mv /var/lib/mysql/mysql.sock /var/lib/mysql/mysql.sock.bak
# service mysqld start
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With