Moving MySql DB To Another Disk/Folder


It happens.....you made a DB then next thing you know your disk is full. If its your OS drive its even worse. The following is a quide to help you move your database files to another mount point / drive.


The databases are stored in /var/lib/mysql, and in this example it will be moved to /hd2


Open the terminal


Stop MySQL with the command



Move existing data directory (which is located in /var/lib/mysql) to new location /hd2



Create symlink from new dir to old one



Restart MySQL with the command



MySQL should now start without any errors. If you do run into errors it is typically caused by permissions. Make sure the new mount point is writable by the mysql user all the way down the path to the mysql folder.