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

IAmAliYousefi
  • 1,132
  • 3
  • 21
  • 33

3 Answers3

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

Tim M.
  • 105
  • 2
  • 8
Aman Aggarwal
  • 17,619
  • 9
  • 53
  • 81
2

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

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

Ike Walker
  • 64,401
  • 14
  • 110
  • 109
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)"

utdrmac
  • 731
  • 5
  • 17