WordPress.org

Ready to get started?Download WordPress

Forums

WordPress database error: [Duplicate entry '0' for key 1] (11 posts)

  1. misslisa
    Member
    Posted 7 years ago #

    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.

  2. torusturtle
    Member
    Posted 7 years ago #

    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!

  3. godrox
    Member
    Posted 7 years ago #

    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?

  4. jonasb
    Member
    Posted 7 years ago #

    It worked for me!

  5. redstone_
    Member
    Posted 7 years ago #

    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

  6. keywordguy
    Member
    Posted 7 years ago #

    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.

  7. nofilmschool
    Member
    Posted 7 years ago #

    torusturtle, I have no idea how you knew this but it saved my butt. thanks!

  8. TBALandry
    Member
    Posted 7 years ago #

    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?

  9. taglad
    Member
    Posted 7 years ago #

    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

  10. giovanny
    Member
    Posted 7 years ago #

    This worked great. Thx a lot for the tip!

  11. paul
    Member
    Posted 6 years ago #

    worked for me as well. Thanks to Google for finding it.

Topic Closed

This topic has been closed to new replies.

About this Topic