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

How to delete master and slave by mysql

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

Today, the editor will share with you how mysql deletes the relevant knowledge points of master and slave. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article. Let's take a look at it.

Mysql delete master-slave methods: 1, using the "stop slave;" statement to stop the master-slave synchronization of the slave server; 2, using the "RESET MASTER;" statement to reset the master service; 3, using the "reset slave;" statement to reset the slave service; 4, restart the database.

The operating environment of this tutorial: windows10 system, mysql8.0.22 version, Dell G3 computer.

How to delete master and slave by mysql

After creating the database master-slave configuration, if you want to delete the database master-slave service, you can delete the database master-slave according to the following steps

1. Stop master-slave synchronization of the slave server

In order to prevent master-slave data from being out of sync, you need to stop the synchronization service on slave first.

STOP SLAVE

two。 Lock the database of the master server

In order to avoid updating the database during backup, the database must be locked.

FLUSH TABLES WITH READ LOCK

3. Backing up data on master

Mysqldump-u root-p-databases db1 db2 > bak.sql

4. Reset the master service

RESET MASTER

RESET MASTER-- deletes all binary logs and creates an empty log of. 000001. RESET MASTER does not affect the working state on the SLAVE server, so blindly executing this command will cause slave not to find the binlog of master, causing synchronization to fail, and we have to delete synchronization, so we must execute it.

5. Unlock the database of the master server

UNLOCK TABLES

6. Copy the backup files on master to the slave server

7. Delete old data on the slave server

Before deleting, make sure that all of the backups have been backed up.

8. Import data

SOURCE / root/bak.sql

9. Reset the slave service

Stop the slave service first and then proceed

RESET SLAVE

RESET SLAVE-- clears the synchronization location on the slave, deletes all the old synchronization logs, and starts over with the new log, which is exactly what we want. It is important to note that the slave service (STOP SLAVE) must be stopped first, and we have stopped it in the first step.

10. Restart the database

After restarting the database, you are done!

The above is all the contents of the article "how to delete the master and slave of mysql". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.

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