Clearing out spam comments in Drupal 7

Very often for a Drupal installation, we come across hundreds of spam comments, in spite of installing spam blockers such as Mollum.

If you do need to remove comments manually, the best method is by connecting directly to your MySQL instance and executing the following set of SQL queries.

DELETE FROM comments WHERE status = 1;

DELETE `field_data_comment_body`.* FROM `field_data_comment_body` LEFT JOIN comment ON field_data_comment_body.entity_id = comment.cid WHERE comment.cid IS NULL;

DELETE `field_revision_comment_body`.* FROM `field_revision_comment_body` LEFT JOIN `comment` ON field_revision_comment_body.entity_id = comment.cid WHERE comment.cid IS NULL;

If you have Mollum installed, you should execute the query below also.


Leave a Reply

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