DISCLAIMER: this post is older than one year and may not be up to date with latest WordPress version.

Mark just asked me how can he delete more than 6000 spam comments he received on his blog during his holidays.

First of it all, backup your WordPress database. Then, login to your phpmyadmin, select your WordPress blog database and click on SQL:
Batch deleting spam comments on a WordPress blog

Then, insert the following sql command:

DELETE from wp_comments WHERE comment_approved = '0'; 

All non-approved comments we be deleted. But instead of having such trouble next time, you should definitely install Akismet!


  1. How can I delete all the comments? I have 400,000 spam comments which are approved.

  2. Hi there,

    This is the clearest post I’ve read about this problem, so thanks. Do you know if there is a way of deleting spam comments that have been marked ‘approved’ without deleting my legitimate comments, which are also marked ‘approved’?


  3. How about the table called “wp_commentmeta”? That one has also data concerning the comments. Does it mess up the database (or at least leave a lot of unneeded data) if that table is untouched? I’d say that touching only the wp_comments table is not a proper way to handle the spam, unless the identical id-values are cleaner from the wp_commentmeta table.

    I’d love to see a simple solution for that…

    Also, I got 3 installation of multisite-wordpress’ and each blog in each wordpress has it’s own spam-comments. I’d love even more to see a plugin/tool to clean ALL those sub-blogs in a single stroke 😀

    @Kaira: check out similar post here, which shows howto delete all comments at once: http://techfreakz.com/itwebsites/content-management/wordpress/cleaning-up-wordpress-comments-mass-deleting-wordpress-spam-comments-mass-deleting-wordpress-comments/

  4. You can use the code provided in this blog post to delete ALL approved comments. Simply change the 0 to 1. (comment_approved = ‘1’)

    Please use with care as this deletes ALL approved comments. If you are certain there are no comments you want to keep, this works.

  5. sweet thanks… how do you do it for trash?

  6. Wow, thanks for the tip. I have comments open in my new site. In case I get spam , I’ll know what to do.

  7. Even akismet can’t handle most of them. Guess this is one of the major issue that needs to be handled in wordpress. May be some captcha plugin would help..
    I tried the same syntax with variations over time but how about the few genuine comments 🙁

    DELETE from wp_comments WHERE comment_approved = ‘0’;
    DELETE from wp_comments WHERE comment_approved = ‘spam’;
    DELETE from wp_comments WHERE comment_approved = ‘trash’;

  8. It worked great. It was so simple I was amazed. Thank You – you are a genius!

  9. Awesome! This totally worked like a charm. My client had accumulated 18,000+ spam comments over the last 4 years. Luckily, none of them had been “approved.”

    Thanks a ton for the database/phpMyAdmin help:

    DELETE from wp_comments WHERE comment_approved = ’0′;

  10. Brilliant, works like a charm, thanks!

  11. Thank you sooo much. The monthly bandwidth of this site due to spam was more thab 20 GIGs. I just deleted with your instructions “60560 rows (spams)deleted. ( Query took 3.9377 sec )” EXACTLY!!!!

  12. Hi there. I used your suggestion and it deleted all the comments (thanks), but the posts still show the previous comment count despite there being zero comments on the entire blog. I deleted the commentsmeta as well but it doesn’t seem to have worked. Do you have any suggestions?

  13. Hello,

    Instead of using 0 as the amount i choose the amount of 1 and got rid of all the comments.

    / Marcus

  14. where does one enter this code in wordpress for it to get activated?

    DELETE from wp_comments WHERE comment_approved = ’0′;
    DELETE from wp_comments WHERE comment_approved = ‘spam’;
    DELETE from wp_comments WHERE comment_approved = ‘trash’;

  15. Great tip. I just deleted 18,945 comments, boy I’m grateful.

  16. In the WP admin interface if you go Dashboard > Comments > Spam there is a button “Empty Spam” which does the same job. The script runs “forever” and results in an empty page! You may have to run it several times but this approach may be safer than messing with the database.

    I just got rid of 100+ megabytes of spam and back under my ISP database quoter!

    May be a good idea to press this button from time to time to prevent a build up.

  17. Hi My host, Siteground, has shut down my site until I clear all of the Spam comments out.

    I have stopped new registrations. I have installed a disable comments plugin. How do I get rid of thousands of spam comments from 300+ multisites from network admin? None of them will have been approved. If necessary I am happy to delete all comments.

    Is there a way to do it without having to login to each individual site or find each individual comments table in mysqladmin?

    Many thanks, Mike.

  18. Do any of you know of a script/plugin that could do this as a novice? The Akismet when you install it afterwards has a timeout problem deleting 100k plus comments. To those who read this and can program — next to Akismet such a plugin will get alot of support.

  19. This is awesome! I have 2000 spam comments and I always get nervous using PHPMYADMIN.

    Cheers Dude!

  20. Check out this plugin


    It worked a treat for me and no need for any sql coding.

  21. Thanks so much. Worked like a charm. I had to get rid of 3200+ comments marked as spam.

    You rock!

Leave a Comment

Your email address will not be published. Required fields are marked *