Deleting unneccesary database tables

Hi all,
I really need help with WP databases in MySQL.
I recently had to revert to a backup of WordPress and also delete some Sites and Plugins.
When I try to go back and add the Sites again, it tells me that there are already existing tables in the Database.
How can I delete them so I can re-add the Sites using the same names, and also clean out unnecessary tables from plugins that I've decided not to use? I've looked into a few plugins but they are all a few years old.
Any help would be greatly appreciated!

  • Adam Czajczyk

    Hello HItt-Girl,

    I hope you're well today and thank you for your question!

    It seems like the database got "messed up" a little and that's a bit tough case. Information about sites are stored in different places so the clean-up would most likely require reviewing database manually. I think however you could give this plugin a try for the start:

    If that doesn't help, let me know and I'll dig deeper.

    Kind regards,

  • Hitt-Girl

    Hi Adam! Thanks for replying :slight_smile:
    I installed and ran the WP-Optimize plugin, and it did find and delete quite a few unnecessary database stuffs. I think it will be useful in helping to keep the DB a little cleaner.
    Unfortunately, when I try to add the first Site, it still tells me that it already exists. Also when I view the table information in WP-Optimize after running a full optimization, I still see tables in the DB for plugins that I deleted (like Woocommerce and Huge IT, among others.) So I guess we keep diggin? :disappointed: thanks again

  • Dimitris

    Hey there Hitt-Girl,

    hope you're doing good and don't mind chiming in! :slight_smile:

    Each subsite has a unique ID and that ID is used in database tables. For example, if you have wp_ prefix and you look for posts table, for your main site it will be wp_posts and for subsite with ID 2 it will be wp_2_posts. Based on that you can search for blog ID's that don't exist in your current site list and remove those tables.

    In order to do so you should use a program like phpMyAdmin which is offering in most hosting packages. Feel free to contact your hosting provider on how to access your database and please keep in mind to perform a database export before making any changes so you could import it back if something goes wrong.

    About other DB tables coming from old plugins, you should also delete them manually via phpMyAdmin.

    Warm regards,

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.