Skip to content

Instantly share code, notes, and snippets.

@stollcri
Last active December 18, 2015 15:14
Show Gist options
  • Save stollcri/ea6c93c8a69cedad0f21 to your computer and use it in GitHub Desktop.
Save stollcri/ea6c93c8a69cedad0f21 to your computer and use it in GitHub Desktop.
Forward a MySQL slave past problematic SQL commands
# It may become necessary to tell a MySQL replication slave to skip commands it
# is supposed to replicate. For eaxmple, if a table is deleted from the slave
# server and then it is deleted from the master server, the replication process
# will direct the slave to delete the table; since the table does not exist,
# the command cannot procees, and the replication gets stuck. The replication
# status on the slave cna be checked using 'SHOW SLAVE STATUS'. The slave drives
# replication, so the only way to check the stat us on the master is by using
# 'SHOW PROCESSLIST'
# see also:
# https://dev.mysql.com/doc/refman/5.7/en/replication-administration-status.html
# The first step is to verify that this is the cause.
tail -f /var/log/mysql/error.log
# Check if there is an error due to an un-runable command
# Then, open a connection to the slave server and run the following command
# to skip past the bad command. Watch the error log output
STOP SLAVE; SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1; START SLAVE;
# Repeat as necessary
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment