Article ID: 119334, created on Dec 26, 2013, last review on Nov 1, 2015

  • Applies to:
  • Plesk for Linux/Unix


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 mysqld will not start at all.
  • After relocating the MySQL datadir or changing the default port, MySQL does not start.

For all the above cases there is a common symptom. You are unable to start the 'mysqld' service with error:

[root@server ~]# /etc/init.d/mysqld start
Another MySQL daemon already running with the same unix socket.
Starting mysqld:                                           [FAILED]


The socket was not removed after an incorrect MySQL service stop.


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 -

Issue discussion on the MySQL bug tracker -

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/' (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/ 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 

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  ]

Search Words


ERROR: PleskMainDBException: MySQL query failed: Unknown table engine 'InnoDB' (db.php:102)

Unable to connect to database: mysql_connect

unsupported protocol version

mysql online

a914db3fdc7a53ddcfd1b2db8f5a1b9c 56797cefb1efc9130f7c48a7d1db0f0c 29d1e90fd304f01e6420fbe60f66f838

Email subscription for changes to this article
Save as PDF