Restart MySQL Master-Slave: Step-by-Step Guide

The steps for restarting MySQL master-slave are as follows:

  1. Stop the replication process on the slave server.
STOP SLAVE;
  1. Stop the replication process on the master server.
STOP MASTER;
  1. Restart the MySQL services for both the master and the slave servers separately.
service mysql restart
  1. Reconfigure master-slave replication on the primary database, which includes regenerating binlog files and position information.
  2. Reconfigure the master-slave replication on the secondary database, including updating the information on the master database and starting the replication process on the secondary database.
CHANGE MASTER TO MASTER_HOST='主库IP', MASTER_USER='用户名', MASTER_PASSWORD='密码', MASTER_LOG_FILE='binlog文件', MASTER_LOG_POS=binlog位置;
START SLAVE;
  1. Check if the status of master-slave replication is normal.
SHOW SLAVE STATUS\G

By following the above steps, you can ensure that there are no issues with data synchronization when restarting MySQL master-slave replication.

bannerAds