The bad thing about cpanel is that it expects mysql datadir to be in /var/lib/mysql/ no matter what you specify in my.cnf. I copy the /var/lib/mysql/ to /drive2/mysql/
CODE
cd /var/lib
cp -Rp mysql /drive2/
If all went well, the old data dir can be renamed or deleted
CODE
mv mysql mysql_old
The mysql.sock never gets copied to /drive2 so I need to create it again and also help cpanel find the mysql.sock that will be created in /drive2/mysql, I make a link from /var/lib:
CODE
ln -s /drive2/mysql mysql
I put this in my.cnf:
CODE
datadir = /drive2/mysql
socket = /drive2/mysql/mysql.sock
then I execute mysqld_safe start (the purpose is to recreate the mysql.sock) and after the command completes, restart mysql from within whm.
that's it
Some more on backup:
Since I use my second drive to backup cpanel accounts, now after moving mysql datadir to this drive it is more wise to backup myslq data on the primary drive so that whichever drive gets corrupted, you still have all data on the other one.
So on the primary drive I have a directory /backup and then have this running twice a week as cronjob
CODE
mysqldump --flush-logs --delete-master-logs --master-data --all-databases > /backup/backup_all_mysql.sql --default-character-set=cp1251 --quote-names
upon making the backup, this also deletes all binary transaction logs because they are no more needed. This .sql file plus the binnary logs will always be able to restore your myslq dbs without any loss. For example if you had the cronjob run on sunday, and you got a crash on tuesday and lost all mysql databases, then you first restore from the .sql file, and then (provided that you also kept the binary logs on the drive different from where mysql datadir is - I keep them together with the .sql files in /backup) restore all update/delete transactions made sunday through tuesday from the binnary log.