Unable to add new posts and page at my wordpress site

Username (e.g. epiz_XXX) or Website URL

(username (epiz_30950438) website URL - latestsarkarijobsindia.com)

Error Message

( WordPress database error: [Duplicate entry ‘0’ for key ‘PRIMARY’]
INSERT INTO wp1t_posts (post_author, post_date, post_date_gmt, post_content, post_content_filtered, post_title, post_excerpt, post_status, post_type, comment_status, ping_status, post_password, post_name, to_ping, pinged, post_modified, post_modified_gmt, post_parent, menu_order, post_mime_type, guid) VALUES (1, '2022-04-25 15:45:25', '0000-00-00 00:00:00', '', '', 'Auto Draft', '', 'auto-draft', 'post', 'open', 'open', '', '', '', '', '2022-04-25 15:45:25', '0000-00-00 00:00:00', 0, 0, '', ''))

Other Information

(I am viewing this message after de_bugging. I tried to save auto increment value but its not saving showing unchecked )

This is the issue

I assume you are trying to add post via SQL?
How about doing it manually?

2 Likes

I am posting on WordPress because I am using WordPress for site

Please suggest me solution for this error.

I don’t know what to do. I am not a developer. Please you suggest if you have any solution.

I think I fixed it. Normally, I would give you instructions to do it yourself, but the exact steps were new for me too, so I had to try them out first.

phpMyAdmin doesn’t show an error if you try to re-enable Auto Increment. But if you click Preview SQL, and then copy it into the SQL tab, you’ll see this message.

#1062 - ALTER TABLE causes auto_increment resequencing, resulting in duplicate entry '1' for key 'PRIMARY'

So we can’t enable AUTO_INCREMENT because there is a record with ID 1. This is annoying to fix, but not impossible.

Working around this is simple: just find the record with ID 1 in the table, and give it another ID. I just gave it a very high value.

Then, you can retry the query, and it should work now.

With the value saved, you can change the ID of the record you just edited back to 1.

For good measure (I’m not sure if this is necessary), you could also update the AUTO_INCREMENT value to make sure it doesn’t overlap with existing values. To do so, check the table to find the record with the highest ID value, let’s say 12345.

Then, we need to set the auto_increment value to be one higher than the current maximum, by running this SQL query:

ALTER TABLE table_name AUTO_INCREMENT = 12346;
6 Likes

Yes it is fixed, thanks a ton. I am obliged to you.

2 Likes

Thanks🙏

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.