3

I used replication to migrate all data to a new server, and then I commented out master_host,master_port etc(basically all lines related to master) in my.cnf, I issued stop slave.
However I after restarted mysqld, the replication process is running again! how to stop it for good.

user12145
  • 1,115
  • 6
  • 28
  • 47

4 Answers4

4

The procedure is different based on the MySQL server version.

  • For version 5.0 and 5.1, run STOP SLAVE, CHANGE MASTER TO MASTER_HOST='' and then RESET SLAVE.

In these versions the RESET SLAVE command will remove files master.info and relay-log.info and most of the settings, however some of the settings will just be reset to default values and this is dangerous. If replication is started again, it will start without knowing the master position and so would re-apply all the logs still still available on the master. To to correctly remove all the info about master you need to run also the CHANGE MASTER command.

  • For versions 5.5, 5.6 and 5.7 it is easier, just run STOP SLAVE and then RESET SLAVE ALL.

Here the RESET SLAVE (without the ALL keyword) behaves in the same way - not removing all the info. However also the CHANGE MASTER doesn't help for 5.5+, so you have to be careful and know on which MySQL version you are currently working.

Marki555
  • 1,538
  • 1
  • 14
  • 27
2

The proper way to do this is stop slave; reset slave;

The 'reset slave' is the part that will wipe the config and keep it from reconnecting.

phemmer
  • 5,909
  • 2
  • 27
  • 36
  • is the config stored in the database? – user12145 Feb 10 '11 at 02:46
  • I'm not sure. I believe part of it is stored in master.info as lynxman mentioned, but this command controls that file (at least thats what the doc says). Anyway I've used it and its worked for me. – phemmer Feb 10 '11 at 03:56
  • This is not correct anymore - see http://serverfault.com/a/788912/299496 – Eborbob Jul 29 '16 at 14:32
0

In order to completely stop replication you have two ways

  • Issue a 'CHANGE MASTER` command with fake info, that'll break the replication for good
  • Remove the file master.info that sits on root of your mysql, that'll remove replication info

In any of those cases you'll need to redo your replication later, write down all the replication data like last position and last source-bin file just in case you want to start replication again.

lynxman
  • 9,397
  • 3
  • 25
  • 28
  • no master.info is found on my system – user12145 Feb 10 '11 at 03:05
  • Can a "master.info" file be deleted safely from a running master-DB. I know it's supposed to be there on a slave, but it's a left-over from an import where "CHANGE MASTER" was set on the master... – Henk May 23 '11 at 15:11
0

I usually do an STOP SLAVE; CHANGE MASTER TO MASTER_HOST=''; to kill off a slave.

tex
  • 889
  • 1
  • 9
  • 19