Tag Archives: apparmor

MySQL: change data folder in ubuntu

sudo su
mkdir -p /data/mysql
mv /var/lib/mysql/* /data/mysql
rm -rf /var/lib/mysql
ln -s /data/mysql /var/lib/mysql
chown -R mysql.mysql /data/mysql /var/lib/mysql

edit /etc/mysql/conf.d/datadir.cnf // create this file
[mysqld]
datadir=                /data/mysql

edit /etc/apparmor.d/usr.sbin.mysqld
after
/var/lib/mysql/ r,
/var/lib/mysql/** rwk,

add
/data/mysql/ r,
/data/mysql/** rwk,

/etc/init.d/apparmor reload
/etc/init.d/mysql restart