Learn how to delete WordPress spam comments and meta data with phpMyAdmin. A lot of WordPress spam comments and meta data will keep your WordPress database huge, and slows down your site. It’s best to delete spam comments regularly, but if you’re facing hundreds of thousands spam comments, here is how to delete them all in bulk.
Delete WordPress spam comments and meta data, easily with phpMyAdmin or mysql cli, keeping your WordPress database lean & mean!
Remove WordPress spam comments
In this post I’ll explain how to delete WordPress spam comments, directly in the database and how to delete their meta data. Using the Akismet and WordPress spam comments data, you can start to block comment spammers manually. This sounds as a lot of work but really isn’t.
After blocking comment spammers you can clean their sh?t up. This will keep your WordPress MySQL database small and fast.
Use the following MySQL queries with phpMyAdmin, or the MySQL shell (command-prompt), to check spam comments and delete them.
SELECT * FROM wp_comments WHERE comment_approved = '0';
DELETE FROM wp_comments WHERE comment_approved = '0';
SELECT * FROM wp_comments WHERE comment_approved = 'spam';
DELETE FROM wp_comments WHERE comment_approved = 'spam';
You may also be interested in: How to disable WordPress comments, Delete spam comments after three (3) days and Clean up WordPress post revisions.
Clean-up spam meta data
After deleting the spam comments, it is important to clean up the spam meta data. Either from WordPress or Akismet. This meta data is stored in the table wp_commentmeta. A lot of information is stored there.
First, select the meta data to make sure you don’t accidentally delete other comment information:
SELECT * FROM wp_commentmeta
WHERE comment_id NOT IN (
SELECT comment_id FROM wp_comments
)
If you are satisfied with the outcome, you can delete all spam comment meta data:
DELETE FROM wp_commentmeta
WHERE comment_id NOT IN (
SELECT comment_id FROM wp_comments
)
Do the same for Akismet information. Inspect:
SELECT * FROM wp_commentmeta
WHERE meta_key LIKE "%akismet%"
Satisfied with the result? Delete:
DELETE FROM wp_commentmeta
WHERE meta_key LIKE "%akismet%"
Key Takeaways
- Deleting WordPress spam comments and meta data reduces database size and improves site speed.
- Use phpMyAdmin or MySQL command-line interface to execute queries for bulk deletion of spam comments.
- First, block comment spammers and then clean up their corresponding spam meta data from the wp_commentmeta table.
- Ensure to check spam meta data before deletion to avoid losing other important comment information.
- Follow the provided queries to efficiently manage and delete spam in your WordPress database.
