5

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'... .

3 Answers 3

6

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

2
  • 3
    My vote put your reputation over 1000. You owe me a beer.
    – Dan Bracuk
    Jul 9, 2015 at 13:54
  • Sure, come to India at my place and enjoy a beer :) Jul 9, 2015 at 13:56
2

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

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

2

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)"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.