mysql data/table migration, cold backup
Environmental preparation
Two centos7, close the firewall and selinux
A ——192.168.112.153
B ——192.168.112.172
-153 A terminal operation
1. Install the database
yum -y install mariadb mariadb-server
2. Start the database
systemctl start mariadb
3. Log in to the database, build database and table
create database dyw charset utf8;
use dyw
create table yy(id int(3), name varchar(6));
insert into yy value(7,'tom');
select * from yy;
-Renderings
4. Close the database
myslqadmin -uroot shutdown
Both are wide
systemctl stop mariadb
5. Enter the catalog, package, and send to B
cd /var/lib/
tar zcf mysql.tar.gz mysql/
scp mysql.tar.gz 192.168.112.172:/root/
-172 B-side operation
6. Install the database
yum -y install mariadb mariadb-server
7. Start the database and check the files
systemctl start mariadb
-Renderings
8. Close the database and prepare for cold standby
myslqadmin -uroot shutdown
Both are wide
systemctl stop mariadb
9. Unpack, copy
10. Delete the original datadir path
rm -rf /var/lib/mysql/
11. Modify the configuration file
1~3 add port and socket items
5~6 lines modify datadir directory and socket path
11. Modify the owner/group, add permissions
chown -R mysql:mysql /home/mysql
chmod 700 /home/mysql/test/
12. Start the service, login authentication
mysql startup cannot log in
Add port and socket to the configuration file to
restart, you can log in