Restart MySQL Master-Slave: Step-by-Step Guide
The steps for restarting MySQL master-slave are as follows:
- Stop the replication process on the slave server.
STOP SLAVE;
- Stop the replication process on the master server.
STOP MASTER;
- Restart the MySQL services for both the master and the slave servers separately.
service mysql restart
- Reconfigure master-slave replication on the primary database, which includes regenerating binlog files and position information.
- 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;
- 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.