Skip to content

Instantly share code, notes, and snippets.

@olublessed
Forked from codersofthedark/clean.sh
Created July 21, 2017 21:07
Show Gist options
  • Save olublessed/a5fbf809418cbabb807fdc2f7a797ff0 to your computer and use it in GitHub Desktop.
Save olublessed/a5fbf809418cbabb807fdc2f7a797ff0 to your computer and use it in GitHub Desktop.
MySQL Replication: 'Duplicate entry for PRIMARY key'
while [ 1 ]; do if ['mysql -uroot -ppassword -e"show slave status \G;" | grep "Duplicate entry" | wc -l' -eq 2 ] ; 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 status\G"; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment