WordPress Delete All Comments SQL
We get asked many times “Is there a way in wordpress to delete all comments using sql”?
Well the answer is yes, rather than having to delete around 50 comments a time using the backend of WordPress you can login to the database using a SQL program such as PHPMyAdmin or Navicat and run the following command:-
DELETE FROM wp_comments WHERE comment_approved = 0
This will query the database and find in the table wp_comments an entry that has not been approved yet and delete the entire entry.
An example on clients website there was 10,872 spam comments waiting to be approved. We ran this command to delete all the WordPress comments and the result:-
[SQL] DELETE FROM wp_comments WHERE comment_approved = 0
Affected rows: 10872
Time: 0.422ms
So it took 0.422 milliseconds to remove all 10,872 spam comments.