Restart mysql replication after sql_error

You can use the following commands (on mysql prompt):

mysql> STOP SLAVE;
mysql> SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1;
mysql> START SLAVE;
mysql> SHOW SLAVE STATUS;

The value 1 represents the number of statements to skip. You can do it repeatedly until the replication is fixed. You can see this page.


You don't. Effectively, you need to setup replication again from scratch as you did the first time, because if you just skip statements, you might lose integrity. In order to be safe, you have to replicate from a known safe starting point.

  • Lock the master
  • Dump the data using --master-data and noting the binlog coordinates (e.g. show master status)
  • Unlock the master
  • Load the dump into the slave
  • Start slaving using 'change master' and the binlog coordinates you recorded earlier