Tired of comment spam in your wordpress blog – well if you have access to your wordpress instance and database you can just delete all the unapproved ones
I do a lot of posts – mostly just for my own reference – but others are viewing them also – mostly spammers… unfortunately trying to get their websites higher on googles search list. I don’t think wordpress spam comments really helps them but… they do it anyway.
So here is a brut force method that I use because almost 100% of the comments I get on my blog are spam.
Login to your ec2-user account. Or use phpMyAdmin – to connect (default port is 3306) – sometimes phpMyAdmin is available on your cPanel. I login to aws ec2 with the ec2-user then root but this is likely not necessary.
Point is: connect to the mysql instance that houses your wordpress somehow someway because mysql does home your wordpress blog 99.99% of all blogs… you can change that too but it is not done that often and if it is supported by another type database product you still just have to connect to it, then do the following.
sudo su - mysql -u root -p
Change your database to “wordpress” – or whatever your database name is.
If you are not sure you can do:
If you are still not sure – then:
Your database name is in /var/www/html/wp-config.php under “define(‘DB_NAME’, ‘wordpress’);” your database may not be named wordpress. When you create a wordpress database the name “wordpress” is the default but, it can be overridden.
Delete only unapproved comments
delete from wp_comments WHERE comment_approved = '0'; commit;
The following deletes all comments – careful – if you have some you want to keep don’t run the delete below.
delete from wp_comments;
So you want to see the structure of the table?
describe wp_comments; show tables; # to get the list of all tables in the database