Search This Blog

mysql: changing data directory requires change of apparmor settings

When changing mysql data directory from /var/lib/mysql to /Volumes/Store/mysql:
sudo service mysql stop
sudo mv /var/lib/mysql /Volumes/Store/mysql
sudo service mysql start


Your mysql will fail to start, and run dmesg, you can find the follow error:
[ 2012.069037] type=1400 audit(1357622820.131:47): apparmor="DENIED" operation="mknod" parent=1 profile="/usr/sbin/mysqld" name="/Volumes/Store/mysql/nsp-precise.lower-test" pid=5300 comm="mysqld" requested_mask="c" denied_mask="c" fsuid=0 ouid=0

This is because apparmor are preventing mysqld from accessing unregistered directories.
To solve the problem, edit /etc/apparmor.d/usr.sbin.mysqld as root, and add following lines:
/Volumes/Store/mysql/ r,
/Volumes/Store/mysql/** rwk,


then, start mysql server
sudo service mysql start

See also

  • http://informationideas.com/news/2010/04/15/changing-mysql-data-directory-require-change-to-apparmor/

No comments:

Post a Comment