How to re-sync the Mysql DB if Master and slave have different database incase of Mysql replication?

前端 未结 14 993
小蘑菇
小蘑菇 2020-11-29 14:20

Mysql Server1 is running as MASTER.
Mysql Server2 is running as SLAVE.

Now DB replication is happeni

14条回答
  •  伪装坚强ぢ
    2020-11-29 15:11

    Here is what I typically do when a mysql slave gets out of sync. I have looked at mk-table-sync but thought the Risks section was scary looking.

    On Master:

    SHOW MASTER STATUS
    

    The outputted columns (File, Position) will be of use to us in a bit.

    On Slave:

    STOP SLAVE
    

    Then dump the master db and import it to the slave db.

    Then run the following:

    CHANGE MASTER TO
      MASTER_LOG_FILE='[File]',
      MASTER_LOG_POS=[Position];
    START SLAVE;
    

    Where [File] and [Position] are the values outputted from the "SHOW MASTER STATUS" ran above.

    Hope this helps!

提交回复
热议问题