Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

MySQL - If slave is offline for a few hours and comes back online, does it automatically catch data from master?

share|improve this question
One of my slave server was offline for a few hours and I brought it back up shortly ago, I noticed that the binlog pos #'s matched; but I thought if a slave server goes offline it looses sync? It looks like the data matched too, but I can't tell (20k+ rows) – Mike Jan 20 '11 at 0:19
up vote 5 down vote accepted

In MySQL replication, a slave "syncs" its data from the master's transaction log, not directly from the database. The slave stores the last position in that transaction log, so as long as you have not touched that position number on the slave, then as soon as it becomes active again, it will resume executing transactions from that position it left off at. All should be well for you.

Here you go, for your reference:

share|improve this answer
Beautiful, thank you – Mike Jan 20 '11 at 2:10

yes - however if the master bin log has changed the slave will not be able catch it. the slave keeps track of the bin log file where the master is and the position.

you can check on master

show master status;

on the slave

show slave status;

see if they use the same log file and note the position of the master versus slave. if there are some duplicates into the slave you can always skip records.

share|improve this answer
This i'm aware of; but what i'm not aware of is, when could the master ever change it's log? – Mike Jan 20 '11 at 2:37
it depends by the max size you set. if for example you have a max size of 500 MB after it fills a file will start a new log. – silviud Jan 20 '11 at 5:19
when synced; if the max size is filled; will it automatically jump to the next file? – Mike Jan 21 '11 at 4:05
yes during normal operations the slave will change the log file. there is a way you can make the slave work as well if you have the binlogs - this is when the slave is way out if sync. – silviud Jan 21 '11 at 8:49

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.