Change MySQL Data Dir
Stop MySQL Database:
service mysql stop
edit the following in /etc/mysql/my.cnf
datadir = /srv/mysql
move the existing mysql folder to new location:
mv /var/lib/mysql/ /srv/
if you use an Ubuntu Linux, you have to change all /var/lib/mysql to /srv/mysql /etc/apparmor.d/usr.sbin.mysqld
/srv/mysql/ r, /srv/mysql/** rwk,
then restart apparmor:
/etc/init.d/apparmor reload
at least start the mysql service again:
service mysql start