In this blog,we will see how to resolve the MySQL Replication ERROR 1062 : Duplicate Entry for Primary Key when starting Slave.
Here we will skip the MySQL slave error.
This error,will be raising after successfully establishing MySQL Master and Slave Connection and got error like “MySQL slave duplicate entry with MySQL error code 1062”
When we take dump from Master database,there will be possibility that our Master Database has duplicate entries,but it wont work in the slave.Hence we have to make one change in Configuration file of MySQL “my.cnf”
This means,if the slave host returns the error code 1062,it will skip that query and proceed further.
Once we restart restart mysql/mariadb service.Then login to mysql and run below command.
Now all the duplicate-key errors will get bypassed.
Now lets execute below command to view the Slave status.
Once the “Seconds_behind_Master” gets to 0,we need to remove the below lines from my.cnf and restart mysql/mariadb service.
After few min minutes execute.
Now we can see Seconds_Behind_Master is 0,Now we will remove the below lines and restart the service.
Hope now the issue related to ERROR 1062 Duplicate Entry for Primary Key when starting Slave has been solved.
© 2020, Techrunnr. All rights reserved.