-
Have a backup.
-
Stop MySQL:
sudo service mysql stop
-
Move (or copy) your
mysql
directory. If you want/mnt/mysql
to be the new directory, do it like this:sudo mv /var/lib/mysql /mnt/
-
Open your MySQL configuration (
sudo vim /etc/mysql/my.cnf
) and change thedatadir
value to your new path (e.g./mnt/mysql
) -
Modify your AppArmor configuration:
sudo vim /etc/apparmor.d/usr.sbin.mysqld
Change/copy the lines granting access to
/var/lib/mysql
to your new path. Otherwise MySQL will not start. -
Load your new AppArmor configuration:
sudo service apparmor reload
-
Start MySQL:
sudo service mysql start
Posted by Arne Hartherz to makandra dev (2011-02-22 16:01)