MySQL Red hat linux

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

This is the full step-by-step procedure to resync a master-slave replication from scratch:

At the master:

And copy the values of the result of the last command somewhere.

Without closing the connection to the client (because it would release the read lock) issue the command to get a dump of the master:

Now you can release the lock, even if the dump hasn’t ended yet. To do it, perform the following command in the MySQL client:

Now copy the dump file to the slave using scp or your preferred tool.

At the slave:

Open a connection to mysql and type:

Load master’s data dump with this console command:

Sync slave and master logs:

Where the values of the above fields are the ones you copied before.

Finally, type:

To check that everything is working again, after typing:

you should see:

That’s it!

Leave a Reply

Your email address will not be published. Required fields are marked *