Migration of data in Ubuntu

Source: Internet
Author: User

1. Stop MySQL First

/etc/init.d/mysql stop

2. Create a directory as a directory to temporarily store MySQL data

Mkdir/mysqldata

MySQL data in 3.ubuntu is stored in the/var/lib/mysql directory, and belongs to the MySQL user and MySQL group, the permissions are 700, so we also need to give the migrated directory/mysqldata the same users and groups and permissions

CHOWN-VR Mysql:mysql/mysqldata

chmod 700/mysqldata

4. Copy the contents of the MySQL file to the Mysqldata file, must be root user or not have permission

cp-av/var/lib/mysql/*/mysqldata

5. Modify the MySQL configuration file, ubuntu MySQL configuration file placed in/etc/mysql/my.cnf, modify the My.cnf file as follows:

Comment out the previous DataDir directory add a new DataDir directory

  

6. Also need to modify a file,/etc/apparmor.d/usr.sbin.mysqld, comment/var/lib/mysql/r, and/var/lib/mysql/** rwk, add the following two lines

/MYSQLDATA/R,

/mysqldata/** Rwk,

7 After the modification is complete, restart AppArmor and MySQL.

Service AppArmor Reload

/etc/init.d/mysql start

8. Test Data Migration success

Login database: Mysql-u root-p

Create Database etst; Create a database

This database exists to indicate successful migration

9. Finally, you can safely delete the files under the previous/var/lib/mysql/

Rm-r/var/lib/mysql/*

  

  

Migration of data in Ubuntu

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.