User Tools

Site Tools


linux:ubuntu_mysql_slave_error_1146

MySQL slave error 1146 fix

Slave errors

An example of a queriy in postition 6620 that could not complete. The error code thrown is 1146 and looks like this:

SHOW SLAVE STATUS \G
Last_Error: Error 'Table 'data2.policydata' doesn't exist' on query. Default database: 'mytestdb'. Query: 'ALTER TABLE data2.policydata DROP PARTITION p6620'

How to fix

Please note you can only fix 1 query at the time.

STOP SLAVE;
SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1;
START SLAVE;
SHOW SLAVE STATUS\G;

This tells the slave to skip the first query that failed. If a a second error appears use the line below and so forth.

STOP SLAVE;
SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 2;
START SLAVE;
SHOW SLAVE STATUS\G;

As you can se there is a pattern here SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 2 Means the second query that fails.

STOP SLAVE;
SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 3;
START SLAVE;
SHOW SLAVE STATUS\G;

And again a last time for the last query.

STOP SLAVE;
SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 4;
START SLAVE;
SHOW SLAVE STATUS\G;
STOP SLAVE;
SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 5;
START SLAVE;
SHOW SLAVE STATUS\G;
linux/ubuntu_mysql_slave_error_1146.txt · Last modified: 27/10/2022 13:40 by Allan