Fix Error: Linux “Another MySQL Daemon Already Running With The Same Unix Socket”

For those who run web host servers or virtual servers, you will know that shutting down your server is important to avoid the possibility of data loss and corruption. Though Linux servers  rarely ever need to be restarted, sometimes it becomes necessary – and sometimes external factors may cause your server or machine to perform an unscheduled reboot.

If the reboot is unscheduled, many services including MySQL do not get a chance to shut down properly. Hopefully, your data is safe and has not been corrupted, however upon starting up again a recurring issue for many people is that MySQL fails to start.

This issue can be diagnosed by trying to access a SQL-based website or script on your server. WordPress, for example, gives a Error establishing database connection error.

So here are some steps you can take to fix this error:

How to fix “Another MySQL daemon already running with same Unix socket” error on Linux

This tutorial has been tested and working on a CentOS Linux webhost server. In this particular case, the server shut down without warning and upon a reboot MySQL failed to start. This is because MySQL thought it was already running (since it didn’t shut down properly) and so there is a file we need to delete/remove to clear its memory in order to get it to start up again.

Step 1: Launch the SSH console.

Step 2: We want to ensure MySQL is not running, so we will turn it off using the following line:

service mysqld stop

Step 3: Now we will move a file which is making MySQL think it is already running. You could delete it, but moving/renaming it is safer incase anything goes wrong. So now enter the following into the SSH console:

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

Step 4: With the file moved, let’s try to retart MySQL using the following line:

service mysqld start

Step 5: And with any luck your MySQL service should start up again. This should be confirmed in the SSH console but you can check it under system services if you have Parallels Plesk or cPanel installed – or simply try to connect to a SQL database.

source

Subscribe to Email Updates