WordPress Database Error: Duplicate entry `0` for key 1

Posted on July 13, 2010. Updated July 13, 2010.

Summary

Losing auto-increment attributes will lead to unintended consequences in your Wordpress installation.

After migrating a large WordPress Mu database to a new host, I encountered errors when attempting to create new blogs. This awesome developer posted a solution a few years back, noting auto-increment attributes sometimes get lost when doing MySQL dumps.

To prevent this issue from happening, be sure to use --complete-insert when running mysqldump. The addition of --create-options couldn't hurt.

Here's a quick example:

mysqldump --quote-names --complete-insert --create-options
--user=username --password=password database > dumpfile.sql

This is one of those errors that doesn't make any sense at all, until it sinks in. After awhile, it makes total sense.


2 Responses to "WordPress Database Error: Duplicate entry `0` for key 1"


  1. sandy said:

    August 3rd, 2010 at 9:57 am

    Uzno3n http://fgb7s3Ffjsev7yrbvqqcf7.com

  2. ZigPress said:

    August 11th, 2010 at 9:41 am

    Fantastic life-saving tip - many thanks for posting. I thought I was going mad when a restored WordPress installation wouldn't save any new data! Then I saw the lack of auto-increment on the restored tables, and your post told me why it had happened.

Leave a Reply



XHTML Tag Reference (hover for help)