So, you just came back from summer vacation and now you have 10,000 comments spread across your blogs. What do you do?

Instead of paginating through 20 at a time, and taking hours to delete your comments that you’re sure are not legit anyway, you can mass delete them from phpmyadmin or from the mysql command line instead.

Just login to phpmyadmin, or select the database you want to use via the cli (use databasename;)

Then issue these command for WordPress:

SELECT * FROM wp_comments WHERE comment_approved ="0";
delete from wp_comments WHERE comment_approved ="0";

The first command will show you all the comments, the second command will delete all of the un-approved comments in seconds.

Then issue these command for WordPress-MU:

SELECT * FROM wp_1_comments WHERE comment_approved ="0";
delete from wp_1_comments WHERE comment_approved ="0";

The first command will show you all the comments, the second command will delete all of the un-approved comments in seconds.

That’s it. Now you’ll have all your spam comments removed in a few seconds for each blog you want to remove them from.

You’ll probably want to go through and optimize any tables that are affected after you do a mass delete, just to make sure your site/database run as fast as they can.