Moving the mysql to a new / quicker partition
High CPU from mysql, Full /var but fast /home HDD, Then move your mysql to a new partition for faster response times, Better CPU and lower I/O.
Just follow the guide below for moving the mysql from /var to /home, But please BACKUP ! I will not be held responsible for errors / mistakes.
First stop services that use mysql, such as mysql itself or any httpd applications. Edit and change the my.cnf:
nano /etc/my.cnf #Now in the mysqld section add the following:
pid-file = /home/mysql/mysqld.pid
socket = /var/lib/mysql/mysql.sock
datadir = /home/mysql
basedir = /home/mysql
rsync -vrplogDtH /var/lib/mysql/ /home/mysql/
rsync -vrplogDtH /var/lib/mysql/ /home/mysql/ #Set the mysql.sock so that it functions correctly:
ln -s /home/mysql/mysql.sock /var/lib/mysql/mysql.sock
rm -rf /tmp/mysql.sock
ln -s /home/mysql/mysql.sock /tmp/mysql.sock #Restart the mysql service so it is on the new parition:
killall -9 mysqld
service mysql start
That's it, Reload your website - If it loads then all is good, If not you made a Boo Boo !