Title: WordPress database error: [Duplicate entry &#8216;0&#8217; for key 1]
Last modified: August 18, 2016

---

# WordPress database error: [Duplicate entry ‘0’ for key 1]

 *  [misslisa](https://wordpress.org/support/users/misslisa/)
 * (@misslisa)
 * [20 years ago](https://wordpress.org/support/topic/wordpress-database-error-duplicate-entry-0-for-key-1/)
 * Hi, I recently moved my wp from one location to another and now I can’t seem 
   to make new posts without manually going into phpMyAdmin and editing things to
   make my post appear properly and all that.
 * I get this error:
    WordPress database error: [Duplicate entry ‘0’ for key 1] 
   INSERT INTO wp_postmeta (post_id,meta_key,meta_value) VALUES (‘0′,’_pingme’,’
   1′)
 * WordPress database error: [Duplicate entry ‘0’ for key 1]
    INSERT INTO wp_postmeta(
   post_id,meta_key,meta_value) VALUES (‘0′,’_encloseme’,’1′)
 * Warning: Cannot modify header information – headers already sent by (output started
   at /home/reds7725/public_html/wp-includes/wp-db.php:102) in /home/reds7725/public_html/
   wp-admin/post.php on line 60
 * I went from mysql 4.1.18 down to 4.0.25, which could be the problem but I don’t
   think it is because when I exported the mysql, I selected the option to make 
   it compatible with the older version (and so when I imported the file into the
   old mysql it was fine and came up with no errors).
 * Any help would be much appreciated, thanks.

Viewing 10 replies - 1 through 10 (of 10 total)

 *  [torusturtle](https://wordpress.org/support/users/torusturtle/)
 * (@torusturtle)
 * [20 years ago](https://wordpress.org/support/topic/wordpress-database-error-duplicate-entry-0-for-key-1/#post-390965)
 * Hi Lisa
 * I had the same problem.
    You have to activate **auto increment** for the primary
   ID.
 * How to do it:
    – open phpMyAdmin – select the WordPress database – select table“
   wp_comments” – change the row with the field “comments_id” – select “auto_increment”
   from the last pull down menu in the row – save
 * Now repeat this with all your tables.
 * Hope this helps!
 *  [godrox](https://wordpress.org/support/users/godrox/)
 * (@godrox)
 * [19 years, 10 months ago](https://wordpress.org/support/topic/wordpress-database-error-duplicate-entry-0-for-key-1/#post-391120)
 * I’m having this same problem. I changed web hosts, so I exported the WP database,
   imported it into the new database on the new host, and ran the 2.0.4 install.
   It updated my database (which was still from WP 1.5) and everything seemed to
   be fine until I tried to publish a new post or edit an existing one. Then I get
   this same error:
 * WordPress database error: [Duplicate entry ‘0’ for key 1]
 * Before I go messing with my database, though, can anyone confirm if this fix 
   works or not? And will it cause any problems with future WP upgrades?
 *  [jonasb](https://wordpress.org/support/users/jonasb/)
 * (@jonasb)
 * [19 years, 10 months ago](https://wordpress.org/support/topic/wordpress-database-error-duplicate-entry-0-for-key-1/#post-391121)
 * It worked for me!
 *  [redstone_](https://wordpress.org/support/users/redstone_/)
 * (@redstone_)
 * [19 years, 10 months ago](https://wordpress.org/support/topic/wordpress-database-error-duplicate-entry-0-for-key-1/#post-391122)
 * torusturtle, thanks for your post. This actually worked for me too. I just want
   to know how you knew this? I was close to dumpin my whole blog till I found your
   post.
 * dave
 *  [keywordguy](https://wordpress.org/support/users/keywordguy/)
 * (@keywordguy)
 * [19 years, 9 months ago](https://wordpress.org/support/topic/wordpress-database-error-duplicate-entry-0-for-key-1/#post-391129)
 * I also migrated from a UNIX machine to a LINUX machine. Only variation was that
   I had a 0 (zero) in each “default” field.
 * Be sure to remove the 0 (zero) before saving or you will get a MySQL error message.
 * Other than this fix has worked on 5-6 other blog sites I maintain.
 *  [nofilmschool](https://wordpress.org/support/users/nofilmschool/)
 * (@nofilmschool)
 * [19 years, 9 months ago](https://wordpress.org/support/topic/wordpress-database-error-duplicate-entry-0-for-key-1/#post-391131)
 * torusturtle, I have no idea how you knew this but it saved my butt. thanks!
 *  [tbalandry](https://wordpress.org/support/users/tbalandry/)
 * (@tbalandry)
 * [19 years, 7 months ago](https://wordpress.org/support/topic/wordpress-database-error-duplicate-entry-0-for-key-1/#post-391133)
 * I am having this same problem even though primary keys on all my tables are auto
   incremented. What else could cause this issue?
 * Here is the error text:
    `WordPress database error: [Duplicate entry '147' for
   key 1] INSERT INTO wp_postmeta (post_id,meta_key,meta_value) VALUES ('114','_encloseme','
   1')
 * On review, I notice that the value, ‘_encloseme’is the meta_key for both meta_id#
   s 147 and 148. Could this be related to the above error?
 *  [taglad](https://wordpress.org/support/users/taglad/)
 * (@taglad)
 * [19 years, 6 months ago](https://wordpress.org/support/topic/wordpress-database-error-duplicate-entry-0-for-key-1/#post-391138)
 * How can I do this directly WITHOUT phpmyadmin ?
 * —quote : I had the same problem.
    You have to activate auto increment for the
   primary ID.
 * How to do it:
    – open phpMyAdmin – select the WordPress database – select table“
   wp_comments” – change the row with the field “comments_id” – select “auto_increment”
   from the last pull down menu in the row – save
 *  [giovanny](https://wordpress.org/support/users/giovanny/)
 * (@giovanny)
 * [19 years, 3 months ago](https://wordpress.org/support/topic/wordpress-database-error-duplicate-entry-0-for-key-1/#post-391172)
 * This worked great. Thx a lot for the tip!
 *  [paul](https://wordpress.org/support/users/paul/)
 * (@paul)
 * [19 years, 1 month ago](https://wordpress.org/support/topic/wordpress-database-error-duplicate-entry-0-for-key-1/#post-391177)
 * worked for me as well. Thanks to Google for finding it.

Viewing 10 replies - 1 through 10 (of 10 total)

The topic ‘WordPress database error: [Duplicate entry ‘0’ for key 1]’ is closed 
to new replies.

## Tags

 * [database](https://wordpress.org/support/topic-tag/database/)
 * [duplicate](https://wordpress.org/support/topic-tag/duplicate/)
 * [MySQL](https://wordpress.org/support/topic-tag/mysql/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 10 replies
 * 11 participants
 * Last reply from: [paul](https://wordpress.org/support/users/paul/)
 * Last activity: [19 years, 1 month ago](https://wordpress.org/support/topic/wordpress-database-error-duplicate-entry-0-for-key-1/#post-391177)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
