I was hosting this site isulongseoph.com on a server running cPanel and I used Fantastico scripts installer to install and upgrade my Wordpress blog to version 2.0.3. But I needed to transfer this site to another server. This time on a Plesk server and it had an application vault where there was also an installable Wordpress just like Fantistico, but along the way, I had a bunch of problems.
To cut the story short, I got stuck with one problem. Whenever I post something new on the blog, I got 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 /isulongseoph/wp-includes/wp-db.php:102) in /isulongseoph/wp-admin/post.php on line 60
After searching online, all I got was other people with the same problem but not with a solution.
For people knowledgeable about databases, it was pretty obvious that in the statements above, the post_id is a unique key and writing over it was not allowed. It this is the case, why was this happening all of sudden? Tracing back the problem…
I checked my database and it used to run on MySQL 4.1.19. And on the new servers I was running, it was MySQL 3.23. And I needed to export the data of my Wordpress blog to be MySQL 3.23 compatible using phpMyAdmin.
And after doing so, everything seemed to be fine after importing it to MySQL 3.23 except for one thing I havent noticed. All primary keys in the database that had auto_increment properties were all removed and the auto_increment was no longer working.
If you are experiencing the same problem and is running Wordpress 2.0.3, all you need to do is run the following query in MySQL, you can do this in phpMyAdmin or through MySQL command prompt commands:
ALTER TABLE `wp_categories` CHANGE `cat_ID` `cat_ID` BIGINT( 20 ) NOT NULL AUTO_INCREMENT;
ALTER TABLE `wp_comments` CHANGE `comment_ID` `comment_ID` BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT;
ALTER TABLE `wp_linkcategories` CHANGE `cat_id` `cat_id` BIGINT( 20 ) NOT NULL AUTO_INCREMENT;
ALTER TABLE `wp_links` CHANGE `link_id` `link_id` BIGINT( 20 ) NOT NULL AUTO_INCREMENT;
ALTER TABLE `wp_options` CHANGE `option_id` `option_id` BIGINT( 20 ) NOT NULL AUTO_INCREMENT;
ALTER TABLE `wp_post2cat` CHANGE `rel_id` `rel_id` BIGINT( 20 ) NOT NULL AUTO_INCREMENT;
ALTER TABLE `wp_postmeta` CHANGE `meta_id` `meta_id` BIGINT( 20 ) NOT NULL AUTO_INCREMENT;
ALTER TABLE `wp_posts` CHANGE `ID` `ID` BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT;
ALTER TABLE `wp_usermeta` CHANGE `umeta_id` `umeta_id` BIGINT( 20 ) NOT NULL AUTO_INCREMENT;
ALTER TABLE `wp_users` CHANGE `ID` `ID` BIGINT( 20 ) UNSIGNED NOT NULL AUTO_INCREMENT;
Once that is done, the problem should be fixed already.
Popularity: 2% [?]

September 8th, 2007 at 11:08 am
Ok, so this is over 1 year old but I just found it today!
OMG YOU ARE A GENIUS! I have been having these issues after exporting and importing ( both done in MySQL4.1..) my blog tables (for 4 different blogs mind you!)
I knew there were some auto_increment issues but could never figure out which ones on the wp_post2cat table and another table.
I ran this quick query and PRESTO! It’s all working now!
Thanks!
September 8th, 2007 at 1:30 pm
Thanks Maggie, I’m glad it helped you. Also a word of caution to other people, since this is indeed an old post, maybe in the future this may not fix the problem with the Wordpress guys do a major change database table structures.
So my tip and word of caution is always keep a backup of everything. So just in case everything gets mess up and makes things worse, at least you still have the original copies with less problems.