Unable to start MySQL service. Another MySQL daemon is already running with the same UNIX socket.


2016-11-16 13:09:50 UTC


2017-04-26 14:43:16 UTC


Was this article helpful?

Have more questions?

Submit a request

Unable to start MySQL service. Another MySQL daemon is already running with the same UNIX socket.

Applicable to:

  • Plesk for Linux


This article applies if you face any of the following symptoms:

  • MySQL starts/stops properly when started/stopped with the mysqld service restart, but MySQL does not start when a server is rebooted.
  • After upgrading MySQL binaries MySQL cannot be started.
  • After relocating the MySQL datadir or changing the default port, MySQL does not start.
  • Another MySQL daemon already running with the same unix socket


There are several common cases when the socket file is not removed. Please check the below use cases and apply the appropriate resolution.

1. Incorrect permissions for the '/tmp' directory

The default permissions on CentOS 6.5 are:

    ls -ld /tmp
drwxrwxrwt 3 root root 16384 Dec 23 17:32 /tmp

Check the '/var/log/mysqld.log' for messages that indicate a permissions problem with '/tmp' in CentOS 6.5, which will affect 'mysqld' startup. This '/tmp' problem is likely due to manual maintenance work.

131207 21:15:47 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
/usr/libexec/mysqld: Can't create/write to file '/tmp/ib0h0Wt3' (Errcode: 13)
131207 21:15:47 InnoDB: Error: unable to create temporary file; errno: 13
131207 21:15:47 [ERROR] Plugin 'InnoDB' init function returned error.
131207 21:15:47 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
131207 21:15:47 [Note] Event Scheduler: Loaded 0 events
131207 21:15:47 [Note] /usr/libexec/mysqld: ready for connections.
Version: '5.1.71' socket: '/var/lib/mysql/mysql.sock' port: 3306 Source distribution

When 'mysqld' is starting up, it establishes /var/lib/mysql/mysql.sock, then crashes as a result of the previous error writing to /tmp and the fact that /var/lib/mysql/mysql.sock was not cleaned.

After resolving the permissions problem on /tmp, rebooting CentOS results in a properly running MySQL.

2. MySQL does not shut down gracefully

If the MySQL service does not shut down gracefully during the OS reboot, the old /var/lib/mysql/mysql.sock has been left behind. This prevents 'mysqld' from starting up. Some people were able to reproduce this error on a CentOS 6.5 KVM guest virtual system by rebooting the host CentOS 6.5 system. CentOS is supposed to gracefully shut down the guest systems, but this seems to be failing for 'mysqld' .

Confirmed Red Hat Linux 6.5 bug - https://bugzilla.redhat.com/show_bug.cgi?id=1037650

Issue discussion on the MySQL bug tracker - http://bugs.mysql.com/bug.php?id=71086

Simple steps to reproduce this issue:

service mysqld start
killall -9 mysqld_safe mysqld
service mysqld start

Note! There is no need to apply the patch from the bug link manually, since the fixed package already has been delivered. Just update the mysql-server package:

yum -y update mysql-server

3. SELinux policy

In the '/var/log/mysqld.log' log, you find errors like the ones below:

mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
[Warning] Can't create test file /var/lib/mysql/boxy.lower-test
[Warning] Can't create test file /var/lib/mysql/boxy.lower-test
[ERROR] /usr/sbin/mysqld: Can't create/write to file
'/var/lib/mysql/boxy.pid' (Errcode: 13 - Permission denied)
[ERROR] Can't start server: can't create PID file:
Permission denied
mysqld_safe mysqld from pid file /var/lib/mysql/boxy.pid ended

If you are sure the permissions on the directory '/var/lib/mysql' are correct, check '/var/log/audit/audit.log' . It may contain similar messages that point to Selinux issues:

type=AVC msg=audit(1363866652.030:24): avc: denied { write } for pid=2119
comm="mysqld" name="/var/lib/myaql" dev=dm-0 ino=394
tcontext=unconfined_u:object_r:default_t:s0 tclass=dir

To apply the new policy, allow MySQL to use the '/var/lib/myaql' directory:

semanage fcontext -a -t mysqld_db_t "/datadir(/.*)?"
restorecon -Rv /var/lib/myaql
restorecon reset /var/lib/myaql context
restorecon reset /var/lib/myaql/mysql.sock context

4. Socket

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

  1. Remove the socket file:

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

    [root@server~]# service mysqld start
    Starting mysqld: [ OK ]
Have more questions? Submit a request
Please sign in to leave a comment.