Linux : MySQL InnoDB: Operating system error number 13 in a file operation

By | July 26, 2014

Have you encountered the following error starting MySQL server on a new machine that you’ve copied over the databases folder from another server?

140612 21:38:29 mysqld started
140612 21:38:29 InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
InnoDB: File name ./ibdata1
InnoDB: File operation call: ‘open’.
InnoDB: Cannot continue operation.
140612 21:38:29 mysqld ended

Even though the permissions are correct as followed :

MySQL data directory [/var/lib]

drwxr-xr-x 32 mysql  mysql        4096 Jun 12 21:38 mysql

MySQL databases folder /var/lib/mysql

-rw-rw---- 1 mysql mysql 85983232 Jun 12 20:12 ibdata1
-rw-rw---- 1 mysql mysql 5242880 Jun 12 20:12 ib_logfile0
-rw-rw---- 1 mysql mysql 5242880 Jun 12 20:10 ib_logfile1
drwx------ 2 mysql mysql 4096 Nov 30 2008 mysql

MySQL database [/var/lib/mysql/mysql]

[...]
-rw-rw---- 1 mysql mysql 9494 Nov 30 2008 db.frm
-rw-rw---- 1 mysql mysql 23652 Jan 10 2013 db.MYD
-rw-rw---- 1 mysql mysql 4096 Jan 11 2013 db.MYI
-rw-rw---- 1 mysql mysql 10330 Nov 30 2008 user.frm
-rw-rw---- 1 mysql mysql 1972 May 3 13:11 user.MYD
-rw-rw---- 1 mysql mysql 2048 May 5 00:00 user.MYI
[...]

This issue is probably caused by SELinux. You may disable it…

Edit SELinux configuration file :

/etc/selinux/config

And set the following :

SELINUX=disabled

Reboot your server and start MySQL daemon again :

service mysqld start