Rebuilding an existing slave from a master using cold-copying of /var/lib/mysql, would this be the proper process/order? Anything missing?

  1. master mysql> SHOW MASTER STATUS\G (take notes)
  2. slave mysql> STOP SLAVE;
  3. Shut down master and slave mysqld
  4. Move existing slave:/var/lib/mysql out of the way
  5. Copy master:/var/lib/mysql to slave:/var/lib/mysql
  6. Start master mysqld
  7. Start slave mysqld
  8. slave mysql> CHANGE MASTER TO MASTER_HOST='masterserver',
    -> MASTER_USER='replicationusername',
    -> MASTER_PASSWORD='replcationpassword',
    -> MASTER_LOG_FILE='logfilefromshowmasterstatus',
    -> MASTER_LOG_POS=positionfromshowmasterstatus;
  9. slave mysql> start slave;
  • There will be some time between "SHOW MASTER STATUS" and shutting down mysqld. Might I suggest using "FLUSH TABLES WITH READ LOCK;" then "SHOW MASTER STATUS;" (Take notes). FLUSH tables will make sure all changes are written to disk and with read lock will make sure the database does not change afterward. – racyclist Oct 13 '10 at 21:11
  • Here are step by step instruction how to do this with minimal downtime using Linux LVM snapshots. juhavehnia.com/2015/05/… – Juha Vehnia May 20 '15 at 19:07

I'd suggest referring to a following link:

MySQL MySQL 5.1 Reference Manual 16.1.1 How to Set Up Replication


Other pieces to add to the mix:

step 6.5 Check permissions after moving files

Step 7 - restart slave with mysqld_safe --skip-slave-start &


1.- Stop master and slave mysqld.

2.- On slave move /var/lib/mysq/ to someplace else.

3.- Copy /var/lib/mysql from master to slave.

4.- Check permissions on slave.

5.- On slave (/etc/my.cnf) set --skip-slave-start

6.- Start master and slave mysqld

7.- On slave point to the new master binlog file just created, on position 4.

8.- start slave io_thread, then see if everything is okay

9.- start slave sql_thread and wait the slave to get up to date.

That's it.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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