Write Review

MetaData is a data that gives information on other data elements. It gives information on the data that is contained in a file, a website or an document. In a database, a metadata is used to give information on the formatting, size and other various information. Over the period of time, various posts are created, updated, deleted; the metadata table becomes large and can degrade your website performance. This tutorial will guide on how you can clean metadata in a WordPress database.

Prerequisites

  • A domain name
  • cPanel Credential
  • WordPress database

Step 1:

Login to your Cpanel and locate phpMyAdmin under Database.

How To Clean Meta Data In A WordPress Database

Click on phpMyAdmin to access the dashboard of phpMyAdmin. Click your database name on the left side menu of your phpMyAdmin control panel.


Step 2:

In this example, you will see prefix with the database name. Here the prefix name is mrr_. Your database prefix name will be different from this example.

How To Clean Meta Data In A WordPress Database

Click on the SQL Tab to access the SQL Query window. First we will learn how to remove the mrr_postmeta. Copy the below set of query to the SQL Query window and click Go.

SELECT * FROM mrr_postmets pm LEFTJOIN mrr_posts wp ON wp.ID = pm.post_id WHERE wp.ID ISNULL;
DELETE pm FROM mrr_postmeta pm LEFTJOIN mrr_posts wp ON wp.ID = pm.post_id WHERE wp.ID ISNULL;

How To Clean Meta Data In A WordPress Database

After executing the query, PHPMyAdmin will give information on how many items were removed, or the results were empty. In this way, you can successfully clean your mrr_postsmeta.

Step 3:

You can also clear the comment meta from your database by executing the following SQL Query in the SQL window.

SELECT * FROM mrr_commentmeta WHERE comment_id NOTIN ( SELECT comment_id FROM mrr_comments );
              DELETEFROM mrr_commentmeta WHERE comment_id NOTIN ( SELECT comment_id FROM mrr_comments );
              SELECT * FROM mrr_commentmeta WHERE meta_key LIKE'%akismet%';
              DELETEFROM mrr_commentmeta WHERE meta_key LIKE'%akismet%';

Here, mrr_commentmeta  is the table name with mrr_ being the prefix name.

Conclusion:

By following the above mentioned steps, you can successfully clean your metadata from your WordPress Database.

Check out the top 3 WordPress hosting services:

Was this article helpful?