The method of resetting MySQL master-slave replication
This article is about how to reset MySQL master-slave replication. The editor thought it was very practical, so I shared it with you as a reference. Let's follow the editor and have a look.
Note: after using the method in this article, all bin-log files will be deleted, so you can back up the bin-log files if necessary, and then follow the instructions.
(recommended: MySQL tutorial)
On the secondary server:
First, we need to stop from the server. Log in to the mysql server and execute the following command.
Mysql > STOP SLAVE
On the primary server:
After stopping the slave server, go to the master server and reset the master server state using the following command.
Mysql > RESET MASTER;mysql > FLUSH TABLES WITH READ LOCK
Use the following command to copy the database dump.
# mysqldump-u root-p mydb > mydb-dump.sql
Unlock the table on the primary server after the backup.
Mysql > UNLOCK TABLES
On the slave server:
Use the following command to restore the database backup from the server.
# mysql-u root-p mydb
< mydb-dump.sql 登录mysql并执行以下命令以重置从服务器状态。 mysql>RESET SLAVE;mysql > CHANGE MASTER TO MASTER_LOG_FILE='mysql-bin.000001', MASTER_LOG_POS=1
Start replication from the server after resetting the slave server
Mysql > START SLAVE
Replication has been resynchronized with the new configuration and can be verified using the following command.
Mysql > show slave status G Thank you for reading! On the reset of MySQL master-slave replication method to share here, I hope the above content can be of some help to you, so that you can learn more knowledge. If you think the article is good, you can share it and let more people see it.