Managing comments on your WordPress site via PhpMyAdmin or SQL

This is something interesting and time saving method. Yeah, it’s a bulk, one click option to remove unwanted comments from your WordPress websites. If you are using multiple WordPress websites, this should help you to save many hours. If your WordPress sites are not properly configured against Spam comments, you may receive 100s of comments per day or week.

You can use any of the Anti Spam plugins available on internet, against this type of Spam comments attack on your website. You can remove those comments from the WordPress dashboard

Access WordPress dashboard → Click on “Comments” from the left side tab → You can sort and select comments from there → Select bulk action.

This image will help you on how to do so:

remove-wordpress-comment

But you can only select a maximum of 20 comments from there. That’s the only problem. If you have to remove 1000s of emails this method will be a painful one. Here we are going with a smart solution for this problem. Yeah you can do this from the PhpMyAdmin tab via cPanel/WHM or from the MySQL interface via command line.

How to remove unwanted comments from from your WordPress site?

The comments are categorized as Pending, Approved, Spam and Trash. Here you can select anyone of this to execute the MySQL query.

Step one : Log into cPanel and access PhpMyAdmin.

Step two : Select the database correctly.

Step three : Click on SQL tab; then execute your query.

remove-wordpress-comment-1

Managing approved comments

You can select all approved comments by executing the following command:

use database_name;
select * from wp_comments WHERE comment_approved='1';

To remove all approved comments from your WordPress’s database, use the following query:

use database_name;
delete * from wp_comments WHERE comment_approved='1';

Select and remove all unapproved comments

Here replace 1 in the above command to 0, that’s it.

You can select all unapproved comments by executing the following command:

use database_name;
select * from wp_comments WHERE comment_approved='0';

To remove all unapproved comments from your WordPress’s database, use the following query:

use database_name;
delete * from wp_comments WHERE comment_approved='1';

Managing Spam and Trash comments

remove-wordpress-comment-2

You can select all Spam comments by executing the following command:

use database_name;
select * from wp_comments WHERE comment_approved='spam';

To remove all Spam comments from your WordPress’s database, use the following query:

use database_name;
delete * from wp_comments WHERE comment_approved='spam';

You can select all Trashed comments by executing the following command:

use database_name;
select * from wp_comments WHERE comment_approved='trash';

To remove all Spam comments from your WordPress’s database, use the following query:

use database_name;
delete * from wp_comments WHERE comment_approved='trash';

That’s it buddy!!
Let me know if you have any questions.

Arunlal Ashok

Linux Server Administrator. I'm dealing with Linux servers since 2012. I started this blog to share and discuss my ideas with the world. Check My Profile!! in uPwork (oDesk) and let me know if you need any assistance. Thanks!!

You may also like...

Leave a Reply

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