MySQL data are located under /var/lib/mysql by default, which could cause a problem to corrupt huge database.
Here the steps to change the data directory
To stop mysql deamon, simply drop the command line
to open the my.cnf file
#vim /etc/mysql/my.cnf (this is my server location…it may change…)
datadir=/home/mysql/ #was /var/lib/mysql/
Create a /home/mysql directory and give clearance to mysql
chown -R mysql /home/mysql
chgrp -R mysql /home/mysql
Copy data and preserve permissions, etc.
cp -Rp /var/lib/mysql/* /home/mysql/
Start the mysql service