Online Consultant

How To's & Tips
Post a question on how to do something/or a tip you find helpful!
Subscribe to new posts
Post Icon
Remove spammy comments on your WordPress blog fast and easy - MySQL code

If you have a lot of spammy comments on your WordPress blog that takes forever to remove through the WordPress dashboard, because it's like hundreds of thousands, maybe even millions of spammy comments, there is a faster way to do it.

For a quick way to purge comments you have not approved or have marked as spam, you can perform a quick query directly from phpMyAdmin in your cPanel hosting account.

Step-by-Step Instructions:

  1. Log in to cPanel and open phpMyAdmin.
  2. Select your WordPress database from the left sidebar.
  3. Click on the SQL tab at the top.
  4. Paste and execute the following SQL code:

 

Code: Please login/register for access
Code: Please login/register for access
Code: Please login/register for access
Code: Please login/register for access
Code: Please login/register for access
Code: Please login/register for access
Code: Please login/register for access

Code: Please login/register for access
Code: Please login/register for access
Code: Please login/register for access
Code: Please login/register for access
Code: Please login/register for access

 

What this does:

  • comment_approved = '0' deletes pending/unapproved comments.
  • comment_approved = 'spam' deletes comments flagged as spam.
  • comment_approved = 'trash' deletes items in the comment trash.
  • Cleans wp_commentmeta first so you don't leave unattached rows taking up database space.

Pro Tip:

Make sure your database table prefix matches! If your prefix is customized (e.g., wp_custom_ instead of wp_), adjust wp_comments and wp_commentmeta accordingly. Taking a quick database export/backup before running mass deletes is always a safe habit!

Deleting hundreds of thousands of unapproved spam comments will instantly shrink your database size, free up server resources, and resolve slow SQL_CALC_FOUND_ROWS queries caused by comment checks.

Hope it helps!

If you've got any questions, just ask!

Post Updated
26 days ago

Official UWB Support Team! Contact us directly here!

Similar Topics
 
Topic / Topic Starter
Rating
Last Post
Replies
Views
Forum
Post Icon
-
Post Icon
Re: Upgrading web hosting/server resources, notifications/warnings when you need to upgrade plan
10 years ago
1
54667
Report forum post by:
Report a concern
Comments: