Remove leftover plugin database tables from WordPress

Did you know uninstalling plugins from the dashboard is not enough?

Many website owners have most likely installed and tested several WordPress plugins but are probably unaware that every time they do they are also creating new database tables that are not removed when plugins are uninstalled.

This over time will have an effect on your website as the database starts to accumulate a lot of junk tables and this in turn will increase the size unnecessarily causing load and speed issues.

Note: Please be aware that not all plugins create database tables and some plugins do give you the option to remove them when uninstalled.

Now the reason most plugins do not delete database tables is that the plugin developer hasn’t added the function to do so. It is as simple as that.

So how do you remove unwanted database tables?

There are two ways to do this:

  1. Dig into your database tables and delete them manually via PHPmyAdmin
  2. Install plugins which can do the job for you directly from inside WordPress
Important!: Always backup your database before attempting to make any changes.

Deleting WordPress tables manually via PHPmyAdmin

The first option is not recommended unless you know exactly what you are doing. You will need to know The default WordPress database structure and be able to identify tables that have nothing to do with the core. On top of that, you will need to know which tables belong to which plugins and this can prove to be a little overwhelming.

Let me show you what the WordPress database looks like without any plugins installed. In the example below, you will see that the default database has 12 tables.

On the same database, I have installed the popular security plugin WordFence. You will notice that the database no longer has 12 tables, it now has 32. This is because the plugin has added an additional 20 tables.

Since I have only installed WordFence I can instantly identify the new tables which are not required for WordPress to function. I will now uninstall the plugin and show you what the database looks like after it has been removed.

Voila there you have it, can you tell the difference?

No, you can’t, this is because upon uninstalling the plugin no database tables were removed. Now can you imagine what happens after several days, months, years of constantly adding and removing plugins? The database will start to struggle and you will start noticing that your website is no longer running as fast as it once used to.

As I have identified and know exactly what database tables were added by the plugin I can now go ahead and check the tables and drop (delete) them. I won’t be going into detail about PHPMyAdmin functions today but here is a cool video by HostGator explaining how to DROP database tables.

Use plugins to delete leftover database tables

Using a plugin specifically developed to clean leftover database tables may be the best and easiest option if you do not feel comfortable jumping into PHPMyAdmin. Please remember and I can’t stress this enough, DO NOT attempt to make any changes to your database without BACKING UP. There is no turning back once you have deleted a database table.

The plugin I recommend using is Plugins Garbage Collector. What this plugin does is scans your WordPress database and displays old plugin tables that were left behind.

Once the plugin is installed you will see the following options.

For this example, I am going to remain using WordFence’s database tables as a reference.

As you can see the scan has recognised all tables that are not part of the WordPress core. It shows all database tables left behind by WordFence. I will check all tables and hit Delete Tables.

Result. All left over tables have been removed. Now that may have seemed easy enough to do but remember there was only one plugin installed. If you have removed several plugins you will see loads more tables which you will need to identify and make sure they do not belong to any other plugin that you are currently using. The plugin does assist in this by displaying plugin name and state.

Additional Data

Some plugins also save options within your main WordPress core tables so you may also want to install Clean Options, a neat tool which cleans up any options in your wp_options table which have become orphaned after you deleted the plugin.

Now before you try any of the above I would suggest  you optimise your database to remove any other junk beforehand. For that I recommend you use WP Sweep –  it allows you to clean up unused, orphaned and duplicated data in WordPress. It also optimizes your database tables.


Share on facebook
Share on twitter
Share on linkedin

Found This Useful?

Follow us on Twiiter for the latest updates 

You May Also Be Interested In