Mysql – way to stop MySQL Replication on the master

MySQLreplication

I want the master to stop replicating data to the slave. I know I can do that on the slave with STOP SLAVE;, but I wonder if there is a way to do it in the master.

One possible solution might be to change the server_id to 0, but in this case I'll have to restart mysql in the master for changes to take effect.

What I'm looking for is a statement like STOP MASTER;.

Best Answer

There does not exist a STOP MASTER; command nor is there a manual mechanism from the Master to stop Replication. You would have to go to each Slave and run on of the following:

  • STOP SLAVE; (Kills the IO Thread and SQL Thread)
  • STOP SLAVE IO_THREAD; (Kills the IO Thread only)

Running either of these will get you the following:

  • Clean Recording of the Replication Coordinates in master.info
    • Master_Log_File
    • Read_Master_Log_Pos
    • Relay_Master_Log_file
    • Exec_Master_Log_Pos

The IO Thread is what communicates with the Master. Killing the IO Thread on the Master Side using the KILL command would abort the IO Thread on each Slave. That could corrupt the Clean Recording of Replication Coordinates.