Centos: another MySQL daemon already works with the same unix socket

I have a weird error when starting the mysqld service:

Another MySQL daemon already running with the same unix socket. 

I tried to list the running services and stop them, but the same error occurs when the mysqld service starts.

I can try to remove mysqld and reinstall it, but it will also delete the database?

+74
unix mysql sockets centos6
Dec 05 '13 at 17:59
source share
10 answers

To prevent the problem from occurring, you should gracefully shut down the server from the command line, and not shut down the server.

 # shutdown -h now 

This will stop running services before shutting down the computer.

Based on Centos, an additional method to restore it again when starting 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

+216
Dec 14 '13 at 10:11
source share

TL; DR:

Run this as root and everything will be installed:

 rm $(grep socket /etc/my.cnf | cut -d= -f2) && service mysqld start 



Longer version:

You can find the location of the MySQL socket file by manually sticking it out in /etc/my.conf or simply using

 grep socket /etc/my.cnf | cut -d= -f2 

It will /var/lib/mysql/mysql.sock be /var/lib/mysql/mysql.sock . Then (as root, of course, or with sudo preended) delete this file:

 rm /var/lib/mysql/mysql.sock 

Then run the MySQL daemon:

 service mysqld start 

Removing mysqld will not solve the problem at all. The problem is that CentOS and RedHat do not clear the sock file after a crash, so you need to do it yourself. Avoiding shutting down your system (of course) is also recommended, but sometimes you cannot avoid it, so this procedure will solve the problem.

+18
Jan 09 '14 at 17:16
source share

I found a solution for everyone in this problem, change the socket directory to a new location in my.cnf

 socket=/var/lib/mysql/mysql2.sock 

and service mysqld start

or quick way, as GeckoSEO answered

 # mv /var/lib/mysql/mysql.sock /var/lib/mysql/mysql.sock.bak # service mysqld start 
+4
Dec 05 '13 at 18:31
source share

My solution for this was left over mysql.sock in the directory / var / lib / mysql / from a hard shutdown. Mysql thought it was already working when it was not working.

+3
Dec 6
source share

Just open the error report when the OS provider asks them to put the socket in / var / run so that it will automatically be deleted upon reboot. It is an error to save this socket after a dirty reboot, / var / run is the place for these files.

+2
Jan 23 '14 at 11:29
source share

to automatically clear the .sock file, put these lines in the /etc/init.d/mysqld file right after the "start") code block

 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 do not have a UPS, and often we have power outages.

Sincerely.

+1
Jan 15 '14 at 10:37
source share

It may happen that when the MySQL service does not shut down properly during OS reboot. Remaining /var/lib/mysql/mysql.sock. This prevents mysqld from starting.

These steps may help:

1: start mysqld service killall -9 mysqld_safe mysqld service mysqld start

2: rm / var / lib / mysql / mysql.sock mysqld start service

+1
Apr 22 '14 at 7:13
source share

To start the MySQL service, you can remove the '/var/lib/mysql/mysql.sock' and start the MySQL service again:

Delete the socket file:

 [root@server ~]# rm /var/lib/mysql/mysql.sock rm: remove socket `/var/lib/mysql/mysql.sock'? yes 

Start the MySQL service:

 [root@server~]# service mysqld start Starting mysqld: [ OK ] 

This will help you solve your problem.

0
Sep 29 '14 at 5:03
source share

This simply happens due to the abnormal termination of the mysql service. delete or backup the /var/lib/mysql/mysql.sock file and restart mysql.

Please let me know if in case of any problems ..

0
Jun 06 '17 at 17:26
source share

I just went through this problem and none of the suggestions solved my problem. While I was unable to start MySQL at boot and found the same message in the logs ("Another MySQL daemon is already working with the same unix socket"), I was able to start the service when I came to the console.

In my configuration file, I found the following line: bind-address=xx.xxx . I accidentally decided to comment on this, and the download error disappeared. Since the binding address provides security, I decided to examine it further. I used the IP address of the machine, not the IPv4 feedback address - 127.0.0.1 .

In short, using 127.0.0.1 as bind-address , I was able to fix this error. I hope this helps those who have this problem but cannot solve it using the answers described above.

-one
May 2 '14 at 16:40
source share



All Articles