Clean out your comments

Did you set up a WordPress site and not setup Akismet right away, and now you have a mountain of SPAM to clean out? You can let Akismet do it’s magic, but going through thousands of comments won’t do you any good, and it will take forever.

The easier way is to just clean out your comment database tables directly, and let Akismet start working on your new comments coming in.

All it’s going to take is 2 database queries. But like with any database operations, make sure you have a working backup before proceeding. Nothing should go wrong, but backups are there for the just in case moments.

This assumes you are using wp_ for your prefix. If you are using something else just change that part.

Using a tool like phpMyAdmin or Adminer will make this a little easier if you’re uncomfortable on the command line.

The first query cleans out your wp_comments table.

New comments have comment_approved set to 0. Comments marked as spam have it set to spam. Approved comments have it set to 1.

Next we need to clear out wp_commentmeta of all of the orphaned meta fields now. This is the same process as from my post on cleaning up wp_posts and wp_postmeta tables.

At this point you should now only have database entries for your approved comments.

While you’re in there, don’t forget to┬áselect all of your tables that have overhead and optimize them. It will speed up d shrink your database.

Leave a Reply