Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of resetting MySQL master-slave replication

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report