Remove A MySQL Replication Slave

There might be a time that you no longer need a MySQL slave in your replication setup. You can remove a mysql replication slave using the following instructions.

Log in to your mysql slave and make sure that nothing is accessing the slave database.

Run the following commands.


mysql> STOP SLAVE;

mysql> CHANGE MASTER TO MASTER_HOST=' ';

mysql> RESET SLAVE;

Note: There is a space between the apostrophes. 

You will then need to remove the Slave configuration from your mysql configuration file (my.cnf). You will need to comment out or remove any line that has the following:

  • server-
  • master-
  • relay-

vi /etc/my.cnf

Restart mysql to reload the configuration.


service mysqld restart

You can test that the slave is disabled by checking the slave status and it returns an empty set. .


mysql> SHOW SLAVE STATUS \G
Empty set (0.00 sec)

After the slave is completely offline you might want to remove the database that was replicating so you can go ahead and drop the replicated database and ensure the slave is clean.


mysql> DROP DATABASE databasename;

MySQL replication is now completely disabled and the server is clean of any data you might have replicated to it.

Share :

Related Posts

Join me as I unveil my ultimate developer workspace for 2024. Discover how I've transformed a basic setup into a cosy, productivity-boosting environment from tech to ergonomics.

I have been struggling for a couple of days working with Google Cloud Scheduler and Cloud functions for a project I’m working on. I’ve been working with functions for a while now. It’s a good idea to secure all your functions so that only other cloud services can access them. This can be done using […]