It’s not uncommon to promote a server from slave to master. One
of the key things to protect your data integrity is to make sure
that the promoted slave is permanently disconnected from its old
master. If not, it may get writes from the old master, which can
cause all kinds of data corruption. MySQL provides the handy
RESET SLAVE
command. But as we’ll see, its behavior
has changed along with the MySQL versions and it’s easy to shoot
yourself in the foot if you use it incorrectly. So how do you
safely disconnect a replication slave?
In short
- For MySQL 5.0 and 5.1, run
STOP SLAVE
,CHANGE MASTER TO MASTER_HOST=''
and thenRESET SLAVE
. - For MySQL 5.5 and 5.6, run
STOP SLAVE
and thenRESET SLAVE ALL
. - For all versions, ban
master-user
,master-host
andmaster-password
settings in my.cnf, …