Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

centos: Another MySQL daemon already running with the same unix socket

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?

like image 707
Mas Avatar asked Dec 05 '13 17:12

Mas


3 Answers

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

like image 154
GeckoSEO Avatar answered Nov 20 '22 18:11

GeckoSEO


TL;DR:

Run this as root and you'll be all set:

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

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.

like image 25
iconoclast Avatar answered Nov 20 '22 16:11

iconoclast


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
like image 4
Mas Avatar answered Nov 20 '22 16:11

Mas