Tip: MySQL Replication Error: Duplicate Entry for Key
I have encountered this error, which to my surprise occurred on a slave database.
error 'Duplicate entry '2355476' for key 1' on query ' INSERT INTO logs (DateStamp) VALUES (NOW())
You might be wondering how a slave database could have a duplicate entry while the master and other slaves are running just fine?
Some say that there could be an entry where it was written in the slave and then written again so the duplicate error occurred. Others say that if myisamchk was run in the master, it removed some entries and tries to create those entries again. The slave then attempts to write the same entry, but since myisamchk was not executed on the slave, the entry exists hence the duplication error.
But luckily, found myself a solution to fix the replication error:
mysql> set sql_slave_skip_counter = 1;
Query OK, 0 rows affected (0.01 sec)
mysql> slave start;
Query OK, 0 rows affected (0.00 sec)
This will skip the error and continue on with the replication. Do not forget to start the slave process afterwards.
Related Posts
1 Comment to “Tip: MySQL Replication Error: Duplicate Entry for Key”
Post comment
Search PinoyTux
Subscribe to Email Feeds
Blog Lounge
Popular Posts
Recent Posts
Drop your Card Here
Recent Comments
- baby
on My October Earnings from Adbrite - ramakanth
on My October Earnings from Adbrite - juan kara-an
on Cebu Pacific Airlines is Evil! - Eugene Engelbrecht
on Cebu Pacific Airlines is Evil! - David Beecher
on Howto: Install yum On RHEL 4









I’m having the similar problem but its very often. I was more curios what would be root cause and how to resolve it once in for all. A stable solution that can solve the problem forever
any ideas or anybody ??