Skip to content

Instantly share code, notes, and snippets.

@codersofthedark
Last active April 29, 2021 03:47
Show Gist options
  • Save codersofthedark/cceaa52247e69e2ff965 to your computer and use it in GitHub Desktop.
Save codersofthedark/cceaa52247e69e2ff965 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
@wheelmanstudio
Copy link

First version of the script works fine. Second commit broke it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment