I recently ran into distress with a Wordpress installation of mine, where a homemade script went perfectly overboard, and never stopped running, count posts to the database. Over a few days it added close to 93.000 posts, of which all were duplicates.
With a bit of searching I found the conundrum, but getting into the database to clean up was a bit of a conundrum, since the script was still running. I had to remove the script perfectly from my install in order to stop it!
I was now left with 96.000 something posts, of which I knew 93.000 or so were duplicates! How to clean those up? I could use the manual deal with, which I started on, but I soon realised I would be ancient and grey before that fixed the conundrum.
A bit of Google searching (where else to start your research?) I found a nifty script to help with exactly this conundrum:
DELETE bad_rows.*
from wp_posts as bad_rows
inside join (
select post_title, MIN(id) as min_id
from wp_posts
group by post_title
having count(*) > 1
) as good_rows on good_rows.post_title = bad_rows.post_title
and good_rows.min_id <> bad_rows.id
This solution was found on the Wordpress.org support forum
This solved the conundrum, and my blog is now performing arts normally again.
P.s. remember to back up your database before doing this!
- wordpress remove duplicate posts
- wordpress delete duplicate posts
- computers internet blog
- remove duplicate posts wordpress
- wordpress delete duplicate mysql
- clean up duplicates in mysql
- a mysql script to delete duplicates
- delete all posts mysql wordpress
- find/delete duplicate wordpress posts
- remove duplicate posts from wordpress
{ 5 comments }
eh ? you must have to make plugins for simple user who dont know how to treat their mysql while running that script… so far i like it.. since i was looking for same business too
Cheer
Hi sagbee
I reckon you’re aptly. I should make a plugin for this. Let me reckon a small on how to do it, and I’ll get on it.
Excellent thought by the way
i installed some comment plugin and it made duplicates of all the comments! if you go ahead and make a plug-in add a feature to remove all duplicate comments too!
Thanks for that fantastic script. That saved my site. Not only was my site throwing duplicate posts, it was ’screwing’ with my page format. Just a note for those not familiar with running mysql scripts, make sure to change the wp_posts to no matter what your table is for posts (i.e. mine was set to wp_5ykyp9_posts per my hosting company.) I adjusted to script to reflect that table and it worked perfectly. Thanks again!
This worked fantastic thanks, deleted a few thousand duplicates!
Now Im wondering if here is a way to use htaccess or something to redirect the dead duplicate URLs to the original URLs? I question because many of the duplicates were indexed.
Any suggestions?
Thanks
Comments on this entry are closed.