After you have performed this procedure, the slave should
connect to the master and catch up on any updates that have
occurred since the snapshot was taken.

If you have forgotten to set the
server-id option for the master,
slaves cannot connect to it.

If you have forgotten to set the
server-id option for the slave,
you get the following error in the slave's error log:

Warning: You should set server-id to a non-0 value if master_host
is set; we will force server id to 2, but this MySQL server will
not act as a slave.

You also find error messages in the slave's error log if it is
not able to replicate for any other reason.

Once a slave is replicating, you can find in its data directory
one file named master.info and another
named relay-log.info. The slave uses these
two files to keep track of how much of the master's binary log
it has processed. Do not remove or edit
these files unless you know exactly what you are doing and fully
understand the implications. Even in that case, it is preferred
that you use the CHANGE MASTER TO
statement to change replication parameters. The slave will use
the values specified in the statement to update the status files
automatically.

User comments in this section are, as the name implies, provided by MySQL users.
The MySQL documentation team is not responsible for, nor do they endorse, any of
the information provided here.

Posted by
Brian Kinney
on
September 10, 2015

I had a slave lose sync, and was trying to restore everything, with a minimum of effort.When you want to resync an existing slave that failed and won't resync, I highly recommend using the mysqldump --master-data method.

1) It grabs all files.2) It will put them back where they belong for you.3) It collects the master status, and embeds it as SQL code for use upon restore.4) It does not require you to stop the existing service, as it does the lock and unlock tables for you.

Reminder: you have to START SLAVE; once your MySQL < dump.db is applied.Please then wait a good 90 seconds before expecting a valid answer to the question SHOW SLAVE STATUS; You are looking for a YES on Slave_IO_Running and Slave_SQL_Running fields.Even if you are not immediately in sync, you probably will be soon.