MySQL file access error on symlinked database

You move your MySQL data files to a different location and symlink the moved data directory back into the /var/lib/mysql. But then the MySQL keeps generating file permissons/ownership error (“Can’t read dir of” “(errno: 13)”). You check the permissions but they are OK.

Possible reason is AppArmor blocking software access  to files in “unusual” locations.

Go to /etc/apparmor.d

Open file usr.sbin.mysqld

Add two lines inside the curly braces. Just add them to the end of the main list of directories. You shall add two lines for every single directory, one for the directory itself, another one for the files within it, like this:

/media/mydisk/wordpress/ rw,

/media/mydisk/wordpress/* rw,

Save the file.

Enter the command:

sudo service apparmor restart
Advertisements


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s