Ubuntu perfectly migrates the MySQL database location, using tumysql
Considering the data security issue, we are ready to migrate the database on the server to the cloud hard disk that we just attached. After studying this, this method is the most reliable!
First, create the directory to which the database will be migrated
Copy codeThe Code is as follows:
Mkdir/media/hdb1/db
Copy the original data in linux to the new directory.
Copy codeThe Code is as follows:
Cp-dpR/var/lib/mysql/*/media/hdb1/db
Re-configure attributes for the new directory
Copy codeThe Code is as follows:
Chown mysql: mysql/media/hdb1/db
Modify the file "/etc/apparmor. d/usr. sbin. mysqld"
Copy codeThe Code is as follows:
Sudo vim/etc/apparmor. d/usr. sbin. mysqld
Set
Copy codeThe Code is as follows:
/Var/lib/mysql r,
/Var/lib/mysql/** rwk,
Change
Copy codeThe Code is as follows:
/Media/hdb1/db r,
/Media/hdb1/db/** rwk,
Modify directory
Copy codeThe Code is as follows:
Sudo vim/etc/mysql/my. cnf
For example, replace datadir =/var/mysql with datadir =/media/hdb1/db
Enable server again
Copy codeThe Code is as follows:
Sudo/etc/init. d/apparmor restart sudo/etc/init. d/mysql restart
Success !!!!
The above is all the content of this article. I hope you will like it.