aysabzevar
aysabzevar

Reputation: 1172

how to undo CHANGE MASTER TO

We have a slave that follow the master. In near future, the master will shut down and the current slave will become new master.
After becoming master, how can I undo CHANGE MASTER TO MASTER_HOST='master'... SQL statement that previously executed on slave?
I can execute STOP SLAVE; but I curious to know how to cancel and undo CHANGE MASTER TO MASTER_HOST='master'... .

Upvotes: 6

Views: 3745

Answers (3)

Aman Aggarwal
Aman Aggarwal

Reputation: 18479

No need to UNDO change master info as it will not impact anything. If you still want it for removing details then you can set all values with blank. OR remove master.info file and restart MySQL. The direct command is:

RESET SLAVE;

In MySQL 8 and newer, RESET SLAVE has been deprecated. Use RESET REPLICA instead. RESET REPLICA does not change any replication connection parameters. If you want to remove all of the replication connection parameters, use RESET REPLICA ALL.

Ref. https://dev.mysql.com/doc/refman/8.0/en/reset-replica.html

Upvotes: 7

utdrmac
utdrmac

Reputation: 780

RESET SLAVE will leave behind master.info file with "default" values in such a way that SHOW SLAVE STATUS will still give output. So if you have slave monitoring on this host, after it becomes the master, you would still get alarms that are checking for 'Slave_IO_Running: Yes'

RESET SLAVE ALL wipes slave info clean away, deleting master.info and SHOW SLAVE STATUS will report "Empty Set (0.00)"

Upvotes: 2

Ike Walker
Ike Walker

Reputation: 65587

I believe the command you are looking for is RESET SLAVE:

https://dev.mysql.com/doc/refman/5.5/en/reset-slave.html

Upvotes: 2

Related Questions