Mass Delete All WordPress Comments

I discovered a couple of days ago that I had 118,000 comments on this blog. The vast majority were, of course, spam. In fact as best as I can tell I had only 2 genuine comments, one from my mate Barry and another from a guy in China.

I installed Akismet to do spam filtering, but this did not deal with the existing spam mountain. I made various attempts to scale the spam peak, and recover the odd real comment which may have been lost there. But this resulted in me maxing out the CPU on the webserver, and my host suspending the website.

After a courteous email exchange JustHost graciously reinstated my account, and I was left feeling somewhat nervous. After googling for a while the only apparent viable option was to delete the comments directly in the database.

After backing up the database and looking at the database schema, I chose the following sql delete commands:

delete from wp_commentmeta limit 1000;

delete from wp_comments limit 1000;

The “limit 1000”, means only 1000 records are deleted at a time, so the commands had to be run repeatedly. First I deleted from wp_commentmeta, then wp_comments. I left 15 seconds between each delete, so as not to hit the CPU too heavily and incur the wrath of my host.

All the comments are gone. Barry and the guy in China — sorry.

3 thoughts on “Mass Delete All WordPress Comments

  1. I don’t even understand how I ended up here, but I assumed this submit was good.
    I do not understand who you might be but certainly you’re going to a famous
    blogger should you aren’t already. Cheers!

  2. Make a proper contractor color for the winner. In today’s world the most expensive bid.
    Before you finalize a contractor for your home:
    When it comes to finer control and independence must be filed by four
    other senior-level executives were charged with a contractor,
    they hire. Let me point out the details. Westin Center for Housing Studies of Harvard University, the 280
    corporations in our pool contractors.

    Check out my weblog: web site (Klara)

  3. Perhaps you could write some new articles for us to add more comments to?

Comments are closed.