How to do it...

  1. Stop the slave:
mysql> STOP SLAVE;Query OK, 0 rows affected (0.06 sec)
  1. Execute CHANGE MASTER TO MASTER_DELAY = and start the slave. Suppose you want a 1-hour delay, you can set MASTER_DELAY to 3600 seconds:
mysql> CHANGE MASTER TO MASTER_DELAY = 3600;Query OK, 0 rows affected (0.04 sec)mysql> START SLAVE;Query OK, 0 rows affected (0.00 sec)
  1. Check for the following in the slave status: SQL_Delay: Number of seconds by which the slave must lag the master. SQL_Remaining_Delay: Number of seconds left of the delay. This is NULL when there is delay is maintained. Slave_SQL_Running_State: The state of the SQL thread.
mysql> SHOW SLAVE STATUS\G*************************** 1. row *************************** Slave_IO_State: Waiting ...

Get MySQL 8 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.