MySQL replication get stopped whenever “Duplicate entry” error comes. You can fix this issue to skip such error but it is not recommended, as long as you know really well what are those queries and why they are failing.
In this article I will show you how you can skip these type of error in MySQL.
Skip One Query
You can skip just one query that is hanging the slave using below command.
mysql>SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1; START SLAVE;
There may be situations where you will need to skip more queries. For instance you should need to skip all duplicate error you might be getting:
"1062 | Error 'Duplicate entry 'xyz' for key 1' on query. Default database: 'db'. Query: 'INSERT INTO ..."
Skip All Queries
If you are skipping these queries make sure this will not bring your slave inconsistent. You can add below line into your my.cnf file to skip all queries.
slave-skip-errors = 1062
As mention above I have skipped all 1062 type of error. You can skip also other type of error but again don’t do this unless you understand very well what those queries are and what impact they have on your data.
You can find all error from here.