Change MySql Data Path

sudo su
 
cp -R /var/lib/mysql /home/work/
chown -R mysql:mysql /home/work/mysql
 
vi /etc/mysql/mysql.conf.d/mysqld.cnf
	socket  = /home/work/mysql/mysqld.sock
	datadir = /home/work/mysql
 
systemctl start mysql
cat /var/log/mysql/error.log
	mysqld: File './binlog.index' not found (OS errno 13 - Permission denied)
 
vi /etc/apparmor.d/usr.sbin.mysqld
	/usr/sbin/mysqld {
		/home/work/mysql/ r,
		/home/work/mysql/** rwk,
		...
 
systemctl restart apparmor
systemctl start mysql

refer to:
https://askubuntu.com/questions/1089045/mysql8-wont-start