In cPanel servers, the default MtSQl data directory location would be '/var/lib/mysql'. Sometimes, when /var partition become full, we need to move the MySQL data directory elsewhere.

1. Using df -h command, find out the partition which has enough space to contain MySQL data directory. For eg, let it be '/home'

2. Create a directory under that partition, for eg, '/home/mysql-data'

3. Rsync '/home/mysql-data' with  '/var/lib/mysql' directory.

Code: [Select]
nohup rsync -av /var/lib/mysql/ /home/mysql-data/ &

4. Once the initial Rsync is over, you have to stop the MySQL service in the server and then do a final Rsync. This is necessary because new data could be added to the already Rsync-ed databases while you perform the initial Rsync.

5. Once it is done, set up a symlink that points  '/home/mysql-data' to '/var/lib/mysql' . The advantage of setting up this symlink is that, even after changing the MySQl data directory, you don't have to update any MySQL variables.

6. Start MySQl service. It should work fine.