How to clean up your WordPress database safely

Do you want to clean up your WordPress website’s database and increase the performance of your website? If yes then you are at the right place.

First of all, let’s know what a database actually is.

What are databases?

WordPress website stores theme files, plugin files, media files and so on as files whereas other things like data of plugins, pages and comments, WordPress configuration settings, user credentials, post settings, etc are stored in a database in the form of tables.

WordPress uses MySQL for its database management system.

Also Read: How to create a custom login URL in WordPress?

Why should we clean up WordPress databases?

In our WordPress website journey, we test many themes and plugins and delete them if we do not find them worthy. But the settings and configurations of such themes and files may still be present in the WordPress databases in the form of tables. Such, databases may be loaded when users surf your website and may slow down your website performance. Such bloated databases may slow down your WordPress website and cause other sorts of technical problems. So, I suggest you to optimize your WordPress database time and often.

Some of the reasons to clean the WordPress database are:

  • To remove the unwanted tables from the database
  • To remove the transient files of deleted plugins and themes
  • To make your WordPress website faster
  • To make your WordPress website safer

How to clean up your WordPress database?

So, to clean up the WordPress database for increased performance, we will be using three plugins. One plugin is called WP Rocket (paid) and the other two plugins (we will combinely use these two plugins) are called Advanced Database Cleaner and Plugins garbage Collector (Free).

WP Rocket is a premium speed optimization plugin and it can work magic in cleaning up WordPress databases. Besides, cleaning up your WordPress database, it works in many ways to speed up your website. I personally recommend you to use WP Rocket if you want to speed up your WordPress website by 3X times.

Using WP Rocket (Paid)

As WP Rocket is a premium WordPress plugin, it is not available in the WordPress plugin library and you have to get it from below.

  • After you buy the plugin, download the zip file and From the WordPress dashboard Click Plugins >> Add New >> Upload Plugin >> Choose File (Choose the downloaded wp-rocket.zip) >> Install Now  >> Activate.
Installing WP Rocket
Installing WP Rocket
  • After installing and activating the WP Rocket plugin you head over to Settings from the WordPress dashboard. WordPress Settings >> WP Rocket >> Database.
Database cleanup options in WP Rocket
Database cleanup options in WP Rocket
  • There will be different cleanup options available in the WP Rocket Database options. I suggest you to select everything from Post Cleanup, Comments Cleanup, Transients Cleanup and Database Cleanup
  • Finally, scroll down to the bottom and click “Save Changes and Optimize”. 
Database cleanup in WP Rocket
Database cleanup in WP Rocket.

This is it. You have now successfully cleaned up your database using the WP Rocket plugin without any issues.

Using Multiple Plugins (Free)

In this method, we will be using two plugins called Advanced DataBase Cleaner and Plugins Garbage Collector.

From the WordPress dashboard Click Plugins >> Add New >> Search for Advanced Database Cleaner in the plugin search bar >> Install >> Activate.

Installing Advanced Database Cleaner.
Installing Advanced Database Cleaner.

From the WordPress dashboard Click Plugins >> Add New >> Search for Plugins Garbage Collector in the plugin search bar >> Install >> Activate.

Installing Plugins Garbage Collector.
Installing Plugins Garbage Collector.

Now, we will be using these two plugins in two parts.

First, let’s use the Plugins Garbage Collector.

  • After installing it, go to Tools >> Database Cleanup.
Scanning database using Plugins Garbage Collector
Scanning database using Plugins Garbage Collector.
  • Check the “Show hidden tables” and click “Scan database”.
  • After that, Plugin Garbage Collector will show a list of tables. There will be two kinds of tables “Active” tables with Green and “Unused” tables with red colour.
Database tables.
Database tables.
  • You need to select all the Red unused tables and scroll down to the bottom and click delete.
Cleaning unused database tables.
Cleaning unused database tables.

That’s it. You have now deleted the unused plugin data from your WordPress website’s database.

Now, Let’s use Advanced Database Cleaner.

  • After installing the plugin go to Tools >> WP DB Cleaner >> and select all the Elements to clean.
Cleaning up unnecessary tables using Advanced Database Cleaner.
  • After selecting all, from the bulk actions choose “Clean” and then click apply.

That’s it. You have successfully cleaned post revisions, auto drafts, trashed posts, pending comments, spam comments, trashed comments, pingbacks, trackbacks, orphaned post meta,  orphaned comment meta, orphaned user meta, orphaned term meta, orphaned relationships and expired transients. 

Also Read: How to add a cookie consent in WordPress without using a plugin?

Things you need to keep in mind.

Although this is the safest way to clean your WordPress databases to improve your website performance, some errors while deleting the database may result in serious issues like Your website going down.

In that case, to be safe from such incidents you need to create a backup of your database from your hosting by going to phpMyAdmin.

To be safe from such incidents, I suggest you to use hosting from Hostinger, as it offers one-click restoring of your entire website if anything goes wrong. If your website goes down due to some technical failure or your wrong move, you can go to Hostinger’s dashboard and choose the backup (It has a daily backup so you can choose a backup from any day which you want to restore) and click “Restore” and that’s it. Your whole website will be restored in some minutes.

To wrap up, you should be cleaning up your WordPress database once in a while as it has a direct influence over your site’s speed and performance. 

You can go through this tutorial or watch the video tutorial available on our YouTube channel. If you have any queries, leave a comment below and I will reply you back.

Also Read: How to add an inline related post in WordPress?

Video Tutorial to clean WP database

FAQ’s

How do I reduce my WordPress database?

You can reduce your WordPress database by deleting unused and unnecessary tables. Plus, you can reduce your database size by only installing plugins and themes that you need.

How do I maintain my WordPress database?

You can maintain your WordPress database by cleaning up the database after you uninstall a theme or a plugin.

Wrapping Up

In the post, we discussed two methods to safely clean the WordPress database for increased website speed and security. You can use the paid plugin WP Rocket or use the free plugins called Advanced Database Cleaner and Plugins Garbage Collector jointly to clean your WordPress website’s database.

If you get stuck somewhere or you need to ask something regarding the process, you can always open your heart outs in the comment section.

Leave a Comment