After a while, old comment meta data can sometimes pile up in your database in which it can take up space as well as negatively impact your site performance. In this article, we will show you how to easily clean up the wp_commentmeta tables in your database to remove old comment meta data that no longer applies.
- Create a backup of your database in case anything goes wrong. This steps is critical as you are deleting content directly from your database in bulk.
- Log into cPanel.
- Within cPanel, click on the PHPMyAdmin icon within the Databases section to access the PHPMyAdmin tool.
- On the menu to the left, select your WordPress database. If you are unsure of what database your WordPress site uses, follow our article on identifying your WordPress database.
- Now that your WordPress database is selected, look to the top of the page and click on SQL.
- Inside the text entry field, enter the following:
SELECT * FROM wp_commentmeta WHERE comment_id NOT IN ( SELECT comment_id FROM wp_comments );
DELETE FROM wp_commentmeta WHERE comment_id NOT IN ( SELECT comment_id FROM wp_comments );
- Then, press the Go button at the bottom right.
- If any content was removed, PHPMyAdmin will let you know the number of rows affected. If there was not any content to remove, it would simply say that MySQL returned an empty result.
You should now know how to quickly clean up the wp_commentmeta table in your database. Following these steps regularly will ensure that the table in your MySQL database is running in top shape.