WordPress Tip: How To Mass Delete Spam Comments via Phpmyadmin / MySQL in cPanel

12 Dec

If you are running one of the High traffic WordPress blog & you are not getting enough time to monitor / clean your comments, this tip is for you.

One day when you log into your wordpress dashboard, you might see lot of comments under “Spam”. You click on “Empty Spam” button provided to you in your WordPress Dashboard so that all of these Spam comments are deleted in one go but when you click on it, you see an error popping up. This is due to the fact that the number of Spam comments are probably too high & you are unable to delete these spam comments in one go using your wordpress admin. You can try deleting these wordpress comments in sets of 50 or 100 but that would be time consuming.

In these kind of problems, your best bet is to log into your Cpanel account and delete these comments directly from the MySQL database .

a) Login to your Hosting Cpanel account

b) Click on “PhpMyadmin” under “databases”

c) Pick the correct database name from the “Database” dropdown and then click on “SQL” Tab

d) Copy the following command and execute it in the SQL Window

SELECT * FROM `wp_comments` WHERE comment_approved = "spam"

e) Once you have confirmed that the above query is giving the same number as you see in the wordpress dashboard, execute the following query:

DELETE FROM `wp_comments` WHERE comment_approved = "spam"

Once you have done this, you are done !

You can go to your wordpress dashboard and confirm the same.

One Response to “WordPress Tip: How To Mass Delete Spam Comments via Phpmyadmin / MySQL in cPanel”

  1. Rachel January 22, 2011 at 3:54 am #

    Woot! Thanks a million for the help — esp clear instructions. Saved my day.

Leave a Reply