WordPress: How to Clean up Meta Data | Bluehost Support
  1. bluehost knowledge base

WordPress: How to Clean up Meta Data

This article will explain how-to clean up metadata in a WordPress database.



Important: Back up your database before performing any of the steps in this article. You will be deleting data from the database. Accidentally deleting the wrong information may require restoring your database from a backup. If you are unsure how-to backup your database, please see How to Backup a MySQL Database.

What You Need

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

Open The Database in phpMyAdmin

  1. Log in to your Bluehost control panel.
  2. Open the cPanel section of your account.
  3. On the cPanel, under Databases, click phpMyAdmin
  4. Log in with your cPanel username and password (if prompted). 
  5. Along the left-hand side of the screen, click on the database associated with your WordPress installation.
    phpmyadmin-tables-sample

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 Meta Data

These steps explain how-to clear the comment metadata.

  1. Copy and paste this code into the textbox:
  2. Replace your_prefix_ with your database prefix.
    phpmyadmin-tables-sample-3
  3. Click the go button.

Post Meta Data

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;
    
  2. Replace your_prefix_ with your database prefix.
  3. Click the go button.

Optimize The Post and Comment Tables

  1. At the top of phpMyAdmin, click the structure tab.
    phpmyadmin-tables-sample-4
  2. Select the comments, commentmeta, posts, and postmeta tables.
    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.

For further assistance, you may contact our Chat Support or Phone Support via 888-401-4678. You may also refer to our Knowledge Base articles to help answer common questions and guide you through various setup, configuration, and troubleshooting steps.