WordPress Reset AUTO_INCREMENT ID In Posts

I’ve been testing a massive migration from a proprietary CMS to WordPress (using my WordPress C# client). After about 20 different tests my post IDs in the WordPress MySQL database got out of control. I’d create 3,000 posts in one swoop and turn around and delete them while testing. This made my IDs something like 31,341 after day. This isn’t a huge deal but it’s annoying to me.

Note: If you already have created posts / pages and attached them to categories and then change the post id then they will no longer be related properly.

A quick google search will likely lead you to How to reset AUTO_INCREMENT in MySQL on Stackoverflow. However this won’t work if you are running on the InnoDB engine.

In my case I could just mass delete all the post with a SQL statement. If you have content and run the following commands bad stuff will happen.

I’d only use this if you don’t care about dropping all your posts!



Published by

Andy Brudtkuhl

Andy is a full stack web developer, growth hacker, entrepreneur, bike commuter, seinfeld enthusiast, and daddy to three little girls and two dogs in Iowa.

Leave a Reply

Your email address will not be published. Required fields are marked *