Ubuntu perfectly migrates the MySQL database location, using tumysql

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.