MySQL Issues When Moving DB
On Dabian/Ubuntu systems a few things meed to be done when moving you DB to a location other than /var/lib/mysql.
Edit Apparmor Config
You need to edit the /etc/apparmor.d/usr.sbin.mysqld file.
Look for lines in this file like the ones below:
/var/lib/mysql/ r, /var/lib/mysql/** rwk,
Change the above lines to reflect the new path to your database as shown below:
/{your path}/mysql/ r, /{your path}/mysql/** rwk,
You may also need to change these lines:
/var/run/mysqld/mysqld.pid w, /var/run/mysqld/mysqld.sock w,
to
/run/mysqld/mysqld.pid w, /run/mysqld/mysqld.sock w,
Then restart MySQL.
sudo /etc/init.d/mysql restart
You may have to kill processes before you can start it again.
Add/Change Permissions
The second issue you may run into is an error about permissions:
/usr/bin/mysqladmin: connect to server at 'localhost' failed error: 'Access denied for user 'debian-sys-maint'@'localhost' (using password: YES)'
Look in the /etc/mysql/debian.cnf for the debian-sys-maint password then login to mysql and run the command below changing <password> to the one you found in /etc/mysql/debian.cnf.
$ mysql -uroot -p GRANT ALL PRIVILEGES ON *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY '<password>' WITH GRANT OPTION;
At this point you may have to kill mysql one more times, but subsequent stop/restart commands should work fine.