I moved the data directory of MySQL to a dedicated disk in my home labo (Virtual Machine running Ubuntu Linux 14.04 LTS) by using the following procedure:
- Stop the MySQL daemon by initiating the command:
sudo /etc/init.d/mysqld restart.
- Change the ownership of the target folder (on the dedicated disk):
sudo chown -R mysql /disk/folder. See remark below!
- Change the group ownership of the target folder:
sudo chgrp -R mysql /disk/folder.
- Move the data from the old- to the new directory:
sudo cp -Rp /var/lib/mysql/* /disk/folder/.
- Change the MySQL configuration in the my.cnf file:
sudo nano /etc/mysql/my.cnf. Change the parameter
- Start the MySQL dameon by executing:
sudo /etc/init.d/mysql start.