I had to move the mysql datadir on my ec2 instance to a different EBS volume. After I move it over, and change the datadir setting in /etc/mysql/my.cnf, I kept getting errno 13 when I started mysql, the error in /var/log/mysql/error.log looks like this:
100819 15:10:20 [Note] Plugin 'FEDERATED' is disabled. ^G/usr/sbin/mysqld: Can't find file: './mysql/plugin.frm' (errno: 13) 100819 15:10:20 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it. 100819 15:10:20 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.
errono 13 typically means your datadir permissions are messed up, but I double checked, and mysql owned and had permission to everything in there, I even set the shell of the mysql user from false to a real shell and su to it and I was able to read everything. After about 45 minutes of digging around, I asked on the mysql irc channel, and a user with the handle of thumbs told me to check apparmor config.
I just migrated from jaunty to lucid and had no idea what apparmor was. Turned out it had to know about the datadir change or else it won’t let it start (if you look at /etc/init/mysql.conf then it’s obvious, but upstart was new to me too). After modifying /etc/apparmor.d/usr.sbin.mysqld, mysql started up just fine.
Just thought I should post this here in case anyone is having a hard time figuring this out. I certainly did.
Hi
Thanks a lot for this post. Saved my life.
Thanks again.
Saved me from beating my head on the wall too. Thanks!