TECHIES WORLD

For Techs.... Techniques.... Technologies....

BashLinuxMysql

How to skip errors in MySQL replication

MySQL replication will stop working if there is error running query on slave machine. But there is an option to skip certain errors to make the replication back to running state.

We can collect the error code using the following MySQL query.

>SHOW SLAVE STATUS \G;

Note the error code number in the field "Last_SQL_Errno".

Then open the MySQL configuration file.

#vi /etc/my.cnf

Add the following line to the file and save.

slave-skip-errors = error-number

Where error-number need to be replaced with the error code number that got earlier.

Finally restart the MySQL service.

#systemctl restart mysqld

Now the replication will start running.

Please note that if there is multiple errors to skip, all those can be added in the configuration file as comma separated values to the same variable.

That's all…