Mysql migrates the database through the data file directory

1. Copy all files in the original database data file directory to the data directory
cp -r /var/lib/mysql/ /home/deploy/mysql/data/

2. Check the permissions of the /home/deploy/mysql/data/ directory and
change the database Attribution is mysql
chown -R mysql:mysql /home/deploy/mysql/data/
Change the database directory attribute to 700
chmod 700 /home/deploy/mysql/data/database/
Change the attribute of the data in the database to 660
chmod 660 /home/ deploy/mysql/data/database/*

3. Modify the mysql configuration file
Find the configuration file location
mysql --help | grep my.cnf Change
the datadir in my.cnf to a new path

4. Modify apparmor.d/usr.sbin. mysqld
vi /etc/apparmor.d/usr.sbin.mysqld Change
 /var/lib/mysql/r, /var/lib/mysql/** rwk
 to /home/mysql/r, /home/mysql/** rwk
 reload
 /etc/init.d/apparmor reload

 5. Restart mysql
  service mysql start

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324585541&siteId=291194637