Super user has a nice step by step instructions on how to solve this probelm
Here is an other set of instruction on doing the same thing
Here it is reposted. Go and up vote the original if you can on super user.
After some general confusion about permissions I realized that the problem wasn't that I didn't have my permissions and paths right but that AppArmor was preventing mysql from reading and writing to the new location.
This is my solution:
First stop MySQL so nothing weird happens while you're fiddling:
$ sudo stop mysql
Then move all the database directories to their new home:
$ sudo mv /var/lib/mysql/<all folders> /new-mysql-dir/
Don't move the files, they will be generated by mysql, just move the folders (which are the databases).
Then politely ask AppArmor to allow mysql to use the new folder:
$ sudo vim /etc/apparmor.d/usr.sbin.mysqld
Then tell mysql that the datadir has moved:
$ sudo vim /etc/mysql/my.cnf
change the line:
NOTE: Depending on your database setup you might need to change innodb-data-home-dir etc. as well.
Then restart AppArmor to read the new settings:
$ sudo /etc/init.d/apparmor restart
And start up MySQL again using the new datadir:
$ sudo start mysql
Hope this helps!