fbpx

Switchover From Master to Slave in MySQL

To switchover from a master to a slave in MySQL, you can use the CHANGE MASTER TO command. This command allows you to change the master server that a slave is replicating from.

Here is an example of how you might use this command to switchover from a master to a slave:​

				
					STOP SLAVE;

CHANGE MASTER TO
    MASTER_HOST='new_master_host',
    MASTER_PORT=3306,
    MASTER_USER='replication_user',
    MASTER_PASSWORD='replication_password';

START SLAVE;

				
			

This will stop the slave, change the master that it is replicating from, and then restart the slave with the new configuration. You should also make sure to update any other relevant settings, such as the replicate_do_db and replicate_ignore_db options, to ensure that the slave is replicating the correct databases.

Share:

Facebook
Twitter
Pinterest
LinkedIn

Social Media

Most Popular

Get The Latest Updates

Subscribe To Our Weekly Newsletter

No spam, notifications only about new products, updates.

Categories