Our website has been hit hard with useless trackbacks and pingbacks over the past couple of weeks. Apart of this was our own fault for not using a WordPress plugin like Akismet, and it was time to remove all of the ones that were already automatically approved. There were thousands and thousands of them. Attempting to delete them through the standard WordPress comments page would take forever, as you’re only allowed to display and remove 20 of them at a time, and even then, they’re either moved to the spam folder or moved to the trash can. Using phpMyAdmin is safe, and is incredibly fast for this. We were able to remove over 2,500 of them in just a few minutes.
Before you do anything, make sure you backup your current database. Should something go wrong, you’ll easily be able to restore to it.
First, you’ll need to access your WordPress database with phpMyAdmin, which can usually be found in your web hosting provider’s control panel. For us, it’s 1&1 (we’ll be reviewing their services soon).
Next, choose wp_comments on the left sidebar, and click on the SQL tab.
The SQL query box.
In the “Run SQL query” box, enter in the following:
delete from wp_comments where comment_author like '%hackers%'
This will delete any comments from the wp_comments table with the author of a comment that contains “hackers“. Feel free to replace comment_author with things in the right box such as comment_content (goes through the actual comment itself), comment_author_url (goes through the commentor’s URL), etc. Click on the first Go button to begin. The process should take less than a second, even if there are hundreds of results. You’ll most likely be switching between phpMyAdmin and your WordPress comments pages to see what you’ll need to search for next.
In the end, we went from over 2,500 of the “comments” down to less than 200, all of which are now legitimate comments.
If you have any questions, feel free to leave them down below .
Feel free to follow Brian and The Tech Erra on Twitter.