MySQL ibdata1 permissions error on cloned EC2 instance

innodbMySQL

I am trying to get a Rails app running on a cloned EC2 instance and am running into some permissions issues with my ibdata1 file. On the original instance, everything behaves as expected. However, on the cloned instance, I am seeing the following error when I try to start mysql:

101103  3:56:22 [Note] Plugin 'FEDERATED' is disabled.
^G/usr/sbin/mysqld: Can't find file: './mysql/plugin.frm' (errno: 13)
101103  3:56:22 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
101103  3:56:22  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.

I have tried starting mysql with sudo start mysql, as well as mysqld_safe –user=mysql, and receive the same errors. The entire /data/mysql directory is owned by mysql, and every file in the directory has 660 permissions for user mysql and group mysql. I have tried chmodding everything to 777 and running as different users to little avail.

My ibdata1 file is 76GB, so doing a clean reinstall and hosing that file is undesirable, but I can get away with it in the short term and do a proper backup/restore if needed over the course of the next few days.

I'm not really sure where to go from here — any thoughts?

Best Answer

It appears that this was an apparmor problem. apparmor had permissions to

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

but /var/lib/mysql symlinked to /data/mysql. We needed to add the following two lines:

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

And that appears to have resolved the issue.