[MySQL] Resolve duplicate entry error in MySQL Replication

while [ 1 ]; do if [ $(mysql -uroot -ppassword -e"show slave status G;" | grep "Duplicate entry" | wc -l) -eq 1 ] ; then mysql -uroot -ppassword -e"stop slave; set global sql_slave_skip_counter=1; start slave;"; fi; sleep 1; mysql -uroot -ppassword -e"show slave statusG"; done

Ref. MySQL Replication Error 1062: ‘Duplicate entry for PRIMARY key’

This entry was posted in MySQL. Bookmark the permalink.