SQL Command for Mass Deletion of Moderated Comments in WordPress

With comments marked as spam you can empty the folder (though if there are too many this might be less of load on the server), but there is no easy way to get rid of moderated comments that are spam. And if you get 10,000+, this could take hours to delete manually. Below is a quick trick using an SQL command in phpMyAdmin.

Here’s how:

Make sure you know the proper database for your WordPress blog if you have several installed. You can find this in databases or the wp-config file in the blog directory (use File Manager for this). Once you know the proper database, click on phpMyAdmin in the CPanel dashboard.

From there, find the database of the site that has all the moderated spam.

Screen Shot 2015-03-04 at 10.02.07 AM

After that, look for the wp_comments table in the database, and click on that table.

wp_comments_table

You should now be in the wp_comments table. From there, click on the SQL tab.

You can now add the SQL command DELETE FROM 'wp_comments' WHERE 'comment_approved' = 0

Screen Shot 2015-03-04 at 10.06.08 AM

You’ll get a dialog box confirming the command.

comment_delete_dialog

After that, you should have gotten rid of every commented that has not been approved.