Ubuntu downloads and migrates the MySQL database and changes the MYSQL location for your reference.
First, create the directory to which the database will be migrated
Mkdir/media/hdb1/db
Copy the original data in linux to the new directory.
Cp-dpR/var/lib/mysql/*/media/hdb1/db
Re-configure attributes for the new directory
Chown mysql: mysql/media/hdb1/db
Modify the file "/etc/apparmor. d/usr. sbin. mysqld"
Sudo vim/etc/apparmor. d/usr. sbin. mysqld
Set
/Var/lib/mysql r,
/Var/lib/mysql/** rwk,
Change
/Media/hdb1/db r,
/Media/hdb1/db/** rwk,
Modify directory
Sudo vim/etc/mysql/my. cnf
For example
Datadir =/var/mysql
Change
Datadir =/media/hdb1/db
Enable server again
Sudo/etc/init. d/apparmor restart sudo/etc/init. d/mysql restart
Success !!!!
Note: The "Location of MySQL database migration under Ubuntu" introduced in this article comes from the city without any limitations, and the article is slightly changed.