MySQL doesn't start. Unix socket already exists

So, this is a Centos 6.5 fresh install. After installing Virtualmin I noticed that mysqld doesn't start. It says: Another MySQL daemon already running with the same unix socket.

It is set to /var/lib/mysql/mysql.sock The mysql.sock already exists. If I delete it manually, server will start. Else, it will not.

I can't seem to understand why the .sock is not deleted before attempting to start it after a reboot.

Doing a restart of the service, won't help, although it says it is stopping it. [root@atlantis log]# service mysqld restart Stopping mysqld: [ OK ] Another MySQL daemon already running with the same unix socket. Starting mysqld: [FAILED]

The only solution is to manually delete the mysql.sock.

Any ideea?

Status: 
Active

Comments

Hmm, that is unusual.

What output does this command produce, when that sock file exists:

ls -l /var/lib/mysql/mysql.sock

srwxrwxrwx 1 mysql mysql 0 Dec 8 20:00 /var/lib/mysql/mysql.sock

When I delete the .sock and start mysqld, it looks the same: srwxrwxrwx 1 mysql mysql 0 Dec 9 11:11 /var/lib/mysql/mysql.sock

Yes, indeed, it is unusual... never confronted with something like this. I have even changed in my.cnf the socket file to use, I put mysqld.sock. It starts the mysqld server just fine when mysql.sock exists, but again, after a system restart.

If I do now a clean system restart, from command line using reboot for example, everything boots back in place as it should.

BUT, if the system gets a reset by itself then mysqld doesn't start. If I press the reset button on the server, when it boots mysqld doesn't starts.

Hopefully that will not happen too often, as I have discovered the problem causing the freezing/restarts (bad memory).

What is the output of this command:

rpm -qa | grep mysql

One thing you could do -- this is just a "hack", as they say, but it might help in cases where your server crashed.

If you edit /etc/rc.d/rc.local, you could add a line like this:

rm /var/lib/mysql/mysql.sock

That will make it so that when your server starts, that .sock file is deleted.

Isn't the rc.local executed after all the init scripts, including mysqld is executed, are executed? So in this case I'd rather modify the /etc/rc.d/rc.local/init.d/mysql init script. I will try to compare it with the one on my older server Centos 4.9.

You're absolutely right -- my bad! Adding that to the MySQL init script should do the trick.

FYI, I saw this on one of my systems today as well - it happened after a forced reboot, in which MySQL wasn't shut down cleanly.

I had the same issue:

Another MySQL daemon already running with the same unix socket.

Here is what I used:

SSH into your sever then:

/etc/rc.d/init.d/mysql stop

then

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

then

/etc/rc.d/init.d/mysql start

I am using CentOS 6.5, this happened during an update that froze the server. I restarted then noticed that the MySQL server was down and could not be restarted.