RESET MASTER;
FLUSH TABLES WITH READ LOCK;
Do not close this connection yet
Without closing the connection to the client (because it would release the read lock) issue the command to get a dump of the master
--master-data
=> the CHANGE MASTER TO command is written into the dump file and thus saves the step of executing it after importing the dump file into the slave
mysqldump -u root -p --master-data --all-databases | gzip > dump.sql.gz
UNLOCK TABLES;
STOP SLAVE;
RESET SLAVE;
zcat dump.sql.gz | mysql -uroot -p
START SLAVE;
Check status
SHOW SLAVE STATUS;
You should see
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
and *_Error
columns should be empty