Moving the MySQL data directory Ubuntu 16.04
Verify the existing MySQL installtion:

mysql -u root -p


From the MySQL prompt, do:

select @@datadir;


You should see the current data directory:

/var/lib/mysql/


Exit the MySQL mode:

exit

Stop MySQL:

sudo systemctl stop mysql

Verify that MySQL is stopped:

sudo systemctl status mysql

Copy the data to the new location:

sudo rsync -av /var/lib/mysql /data/newlocation 


(or whatever volume you've created to store the data)    
Create a backup of the existing data volume

sudo mv /var/lib/mysql /var/lib/mysql.bak

Tell MySQL about the new location. Edit the file:

/etc/mysql/mysql.conf.d/mysqld.cnf


and change the datadir directive, to reflect the new location:

datadir=/data/newlocation

Tell AppArmor about it: edit the file /etc/apparmor.d/tunables/alias  and add:

alias /var/lib/mysql/ -&gt; /data/newlocation/,


to the bottom of that file (the comma at the end of the line is NOT a typo).

Then do:

sudo systemctl restart apparmor

Create the minimal directory structure, to pass the mysql-systemd-start checks:

sudo mkdir /var/lib/mysql/mysql -p

Restart MySQL

sudo systemctl start mysql

Check status:

sudo systemctl status mysql

Verify that the new data directory is active:

mysql -u root -p


At the MySQL prompt, enter:

SELECT @@datadir;

Remove backup, once everything is verified to work:

sudo rm -Rf /var/lib/mysql.bak

Restart MySQL

sudo systemctl start mysql

Check status:

sudo systemctl status mysql