When I start my MySQL server, I get this error:

/usr/libexec/mysqld: Can't find file: './mysql/plugin.frm' (errno: 13)
 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
InnoDB: File name ./ibdata1
InnoDB: File operation call: 'create'.
InnoDB: Cannot continue operation.

I have run mysql_upgrade to rebuild it, and it works to rebuild. Before I did that, I removed and installed MySQL. However, when I tried to re-start, I get the same error. I am sure it is not a permission problem, as all files and directories are created by the mysql user.

Could you advise me on how to fix this error?

  • selinux can also cause this problem.
    – Ross
    Jun 27, 2015 at 19:13

7 Answers 7


If you have mysql data directory at non-standard location and your system has apparmor, ensure that /etc/apparmor.d/usr.sbin.mysqld has your data directory whitelisted. The configuration should look like:

/mysql/data/dir/ r, #trailing slash is mandatory
/mysql/data/dir/** rwk,

Apparmor daemon has to be restarted after you make any changes to config.

  • 1
    apparmor comes back to wake us up from time to time, just so we don't forget about him ...
    – Déjà vu
    Feb 2, 2015 at 8:25
  • 1
    Wow! lot of time looking for this answer. Thanks! Mar 13, 2015 at 20:48
  • In my case I also use a custom temp dir, and I found I needed to imitate some lines from /etc/apparmor.d/abstractions/user-tmp. When I put owner /mysql-tmp/** rwkl, /mysql-tmp/ r, into /etc/apparmor.d/local/usr.sbin.mysqld it started working for me on Ubuntu 14.04.
    – amacleod
    Apr 1, 2015 at 2:37

Are you sure that it's not about permissions? errno: 13:

$ perror 13
OS error code  13:  Permission denied

The first thing to try is to change the ownership of the datadir of MySQL, for example, if you run MySQL with user mysql:

chown -R mysql:mysql /path/to/datadir

Another thing to check is if the mysqld process owner (most probably mysql) has the necessary privileges for the destination defined as tmpdir. And if for whatever reason the above doesn't work, try to trace the mysqld process to see where and why it gets permission denied:

strace -fp$(/sbin/pidof mysqld) -o /tmp/my_trace.log
  • I ran into the same issue when upgrading from MySQL 5.1 to 5.7. It appears that user mysql lost ownership of the /var/lib/mysql directory.
    – Rob
    Jan 31, 2016 at 21:15

In my case, I needed to place the MySQL data directory including ibdata1 folder into another partitioning because my ibdata1 was growing too fast and memory issue occurred. For that, I had to change my.cnf file like below.

my.cnf was:

datadir         =  /var/lib/mysql

my.cnf now:

datadir         = /home/ubuntu/data/mysql

I tried,

sudo chown -R mysql:mysql  /home/ubuntu/data/mysql

but still got the same above error. Then I tried to change the /etc/apparmor.d/usr.sbin.mysqld file. It worked well for me.

We should whitelist our new folder in usr.sbin.mysqld.

 # /var/lib/mysql/ r,
 #/var/lib/mysql/** rwk,

Instead of the above lines add,

 /home/ubuntu/data/mysql/ r,
 /home/ubuntu/data/mysql/** rwk,

Then restart MySQL server.


I agree with Dimitre. This problem arises mostly due to insufficient permissions. Change the ownership of MySql root folder to mysql.

chown -R mysql:mysql [mysql root folder]

You might want to change the permission of Mysql scripts to your custom user though.

chown my_mysql:my_mysql [mysqld etc]

This worked for me.


If you're running SELinux the following may help as well...

 $ -> ls -lZa
 $ -> chcon -R -v -u system_u -t mysqld_db_t /var/lib/mysql
 $ -> ls -lZa
  • For me, doing restorecon -R /var/lib/mysql helped to correctly restore SELinux settings for the directory.
    – Sebi
    Feb 19, 2019 at 13:18

I had this issue after I upgraded from 5.5 to 5.6.

Strangely, it looked like the mysql user had been removed and re-created, which had caused all the mysql files to essentially 'lose' their permissions ...

I found this out by going to the mysql dir (Which in my case was not the default dir, as I have moved it) and saw that the owner was just a uuid and guid number ... So, I just ran chown mysql:mysql on all the dirs and files, and voila


This simple chown worked for me also, no more crashing process:

sudo chown -R mysql:mysql  /var/lib/mysql

Thankfully, playing with apparmor gets complicated and hard to edit.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.