Search code examples
mysqlsqlmaster-slavepercona

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


Solution

  • 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