Skip to main content

How to Clean Metadata: Simplifying WordPress Database Cleanup

Cleaning up your WordPress metadata helps keep your website fast, organized, and SEO-friendly. Over time, unnecessary metadata can build up in your database, slowing down performance. This guide will show you how to clean WordPress metadata safely using phpMyAdmin, including removing unused rows and optimizing your post and comment tables for better site speed. From time to time, optimizing the database to improve site performance for your visitors is essential. This article will explain how to clean WordPress metadata.

  • What You Need
  • How to Open the Database in phpMyAdmin
  • How to Remove Rows With No ID
  • How to Optimize the Post and Comment Tables
  • Summary

What You Need

To complete this tutorial, you'll need to know the following information:

  • Before you get started: Back up your database before performing any of the steps in this article. You'll be deleting data from the database. Accidentally deleting the wrong information may require restoring your database from a backup. If you need help with how to back up your database, please see our article on how to back up a MySQL database.
  • The username and password to your Bluehost account. Need help logging in? If you need help or a refresher, this guide will show you How To Log in To WordPress Sites - WP Admin Access.
  • The name of your WordPress database. If you don't have this, please see our article on how to find your WordPress database.

How to Open the Database in phpMyAdmin

  1. Log in to your Bluehost Account Manager.

  2. In the left-hand menu, click Websites.

  3. Click the MANAGE button located next to the website you want to manage. Bluehost Account Manager - Website Manage button

  4. In the OVERVIEW tab, click the PHPMyAdmin button. am-php-my-admin-1

  5. Along the left-hand side of the screen, click on the database associated with your WordPress installation. phpmyadmin-tables-sample

How to Remove Rows With No ID

  1. Note the prefix attached to your database tables. In our example database, all table names begin with wp_rfrz_. This is our database prefix; yours will differ. phpmyadmin-tables-sample-2

  2. Click on the SQL tab. phpmyadmin-tables-sample-sql

Comment Metadata

These steps explain how to clear the comment metadata.

  1. Copy and paste this code into the textbox: ```

SELECT * FROM your_prefixcommentmeta WHERE comment_id NOT IN ( SELECT comment_id FROM your_prefix_comments ); DELETE FROM your_prefix_commentmeta WHERE comment_id NOT IN ( SELECT comment_id FROM your_prefix_comments ); SELECT * FROM your_prefix_commentmeta WHERE meta_key LIKE '%akismet%'; DELETE FROM your_prefix_commentmeta WHERE meta_key LIKE '%akismet%';


2. Replace your_prefix_ with your database prefix.
![phpmyadmin-tables-sample-3](img/wordpress-clean-meta-data_04_163b736d.png)

3. Click the **Go** button.

### Post Metadata
These steps explain how to clear the post metadata.
1. Copy and paste this code into the textbox: ```

SELECT * FROM your_prefix_postmeta pm LEFT JOIN your_prefix_posts wp ON wp.ID = pm.post_id WHERE wp.ID IS NULL;
DELETE pm FROM wp_postmeta pm LEFT JOIN your_prefix__posts wp ON wp.ID = pm.post_id WHERE wp.ID IS NULL;


  1. Replace your_prefix_ with your database prefix.
  2. Click the Go button.

How to Optimize The Post and Comment Tables

  1. At the top of phpMyAdmin, click the Structure tab. phpmyadmin-tables-sample-4

  2. Select the comments , comme****ntmeta , posts , and postmeta phpmyadmin-tables-sample-5

  3. In the drop-down menu labeled With Selected , choose Optimize Table.

The tables should now have unnecessary metadata removed. If you encounter any issues with the website after this procedure, consider restoring your database using your backup.

Summary

Cleaning your WordPress metadata regularly helps your database run better and improves your website’s performance. To remove unused data and optimize your tables for better SEO and speed, follow these steps in phpMyAdmin. Always back up your database before making changes to ensure a safe and smooth cleanup process.