Most of you may already know how to do this, so forgive if this is too simple, but this may be helpful for some dedicated server owners whose /var mount (some hosts use separate partitions for /usr, /var, /home etc) has become full, which is usually do to large databases in /var/lib/mysql. There is usually plenty of room in /the /home partition. This will work on cPanel servers as well.
This simple tutorial lays out the steps involved to copy contents of /var/lib/mysql to /home and then symlink /var/lib/mysql to /home/mysql. Of course adjust accordingly if moving/symlinking to a different mount or directory.
1) Go to webpage that uses mysql to verify working pre-copy
2) Stop mysql service (I will usually also stop cpanel & http service just to be safe).
/etc/init.d/mysql stop
/etc/init.d/httpd stop
/etc/init.d/cpanel stop
3) Do the copy:
rsync -av /var/lib/mysql /home/
4) Verify copied folder same size as source with du:
du -sh /var/lib/mysql
du -sh /home/mysql
5) Move /var/lib/mysql to /home/mysql-bak (essentially removing /var/lib/mysql because the folder must not exist when symlink is created)
mkdir /home/mysql-bak
mv /var/lib/mysql /home/mysql-bak/
6) Create symlink:
ln -s /home/mysql /var/lib/mysql
7) Verify the symlink is correct when listing the contents of new symlinked /var/lib/mysql (you can refer to the rsync copy to make sure the paths are the same - they should be)
8) Restart mysql, httpd, cpanel
9) Verify mysql-reliant webpage is loading without issue
10) You should now have freed up space on /var. Verify with 'df -h'