post-page

Cleaning Up A WordPress Database After Plugins and Themes Are Uninstalled

33
responses

I have been thinking about this post for a while.  It really started to come to me after I went through a server move of my own website which I discussed on this site last month – Moving Your WordPress Site and Database.

I did a lot of manual cleaning of my database to get rid of orphaned tables that had been in the database since the day I first set up a WordPress based website.

The majority of these defunct tables were from either themes or plugins that I had used at different points in the life of WindowsObserver.com.  As you all know you try out a lot of stuff on your site – mine had 3 years worth of it in there!

Of course I had uninstalled the theme or plugin but a majority of these do not remove the information they leave in your database. 

Now I am not a developer and I have never claimed to be one nor will I.  However, I do believe this is a situation that can be resolved.

You see there are quite a few plugins and themes in the WordPress repository that already have this feature built in and I have used a few.

For example – the WP-DBManager plugin by Lester Chan does this.

wpdbmanageruninstall 

This is the uninstall page for the WP-DBManager and as you can see it will remove database information if you opt to uninstall the plugin.  If your just deactivating it or lets say upgrading it then the options in the database will remain intact.

If this can be done then why not across the board. Why not make this a standard for inclusion in the WordPress Extend site?  If your plugin or theme deposits information into a users database then provide an uninstall option to remove that data/tables.

What do you all think about this? Would really like to hear your thoughts of whether I missing something on this being doable?

heading
heading
33
Responses

 

Comments

  1. Otto (215 comments.) says:

    You don’t need to actually offer a whole page in the plugin like that to do uninstall of data.

    Plugins can have uninstall support easily built in, via an uninstall.php file (easiest way). This file simply gets executed when you select to “delete” the plugin from the Plugin Manager. Ideally, the plugin author would use this space to remove options, tables, etc.

    • Richard Hay (32 comments.) says:

      I disagree with this only because sometimes I troubleshoot problems with a plugin by deleting it and reinstalling it. In that case I may not want the database tables to be removed as I intend to put the plugin back in place.

      That is the reason I think it has to be a deliberate step so that you know and understand the database tables are being removed.

      Sometimes there is a lot of data related to a plugin and I would hate to lose that kind of work.

  2. Jared Spurbeck (9 comments.) says:

    The WP-Wiki plugin creates a new user type when it’s installed. It doesn’t delete it, though, even when it’s uninstalled.

    This has caused me a bit of grief, as I’m a novice plugin developer trying to tweak the permissions granted to that user type.

    I guess I can just go into the database manually. Maybe.

  3. quicoto (39 comments.) says:

    I agree, the plugins that insert any table or data should have a nice uninstall process to clean it.

    Lucky me I can digg into the DB and delete the tables.

    Regards

    • Ronald Huereca (32 comments.) says:

      Eh, plugins shouldn’t create their own tables anyway. I have yet to find a case where a plugin couldn’t just use a custom post type, use taxonomies, and/or use meta tables.

  4. Kjetil (4 comments.) says:

    The plugin mentioned can be used to delete obsolete tables. Easy to use and a must for site owners – just be sure to just empty or delete (“drop”) the correct (unwanted) tables.
    Also available here: http://wordpress.org/extend/plugins/wp-dbmanager/
    Kjetil

    • Richard Hay (32 comments.) says:

      That is the one I used to clean up my database in fact. However,if we get an uninstall standard then we do not have to do that anymore.

    • Ricky Buchanan (6 comments.) says:

      For some of us, just knowing which tables are obselete can be tricky – they’re not always named in an intuitive way!

  5. Lester Chan (32 comments.) says:

    Thanks for the plugs Richard =)

    • Richard Hay (32 comments.) says:

      No problem – easy because you do some good stuff.

    • junthit lee (1 comments.) says:

      Love your plugs so much,..
      How if you add more covered to remove unused tags, unused categories, posts trash for the next version,.?

  6. Vladimir (2 comments.) says:

    While plugins without such cleanup/uninstall feature exist another plugin Plugins Garbage Collector could help you. This plugin searches DB tables created by plugins and allows to drop them for plugins removed already from your blog.

    • Richard Hay (32 comments.) says:

      I have just tried this out on a couple of smaller sites I manage – it is very nice and seems to work well.

      Thanks for the recommendation!

  7. Michel Fortin (3 comments.) says:

    There’s another plugin called “Clean Options” and it looks for orphaned options. I’ve used it on some of my larger blogs and it works great.

    http://wordpress.org/extend/plugins/clean-options/

    It not only pulls what it thinks are orphaned entries but also links the entry to a Google search so you can see which plugin it’s tied to.

    • Richard Hay (32 comments.) says:

      Thanks for another recommendation for cleaning up databases. I did use this during part of my database cleaning a couple of months ago and liked the Google link to see what plugin that table might have been related to.

  8. Hikari (26 comments.) says:

    My plugins do that, they give the option to delete its wp-options row, to reset options or to uninstall the plugin.

    The problem is that most developers don’t mind with it. And considering we are developing stuff for free…

    • Richard Hay (32 comments.) says:

      Hikari,

      Thanks for highlighting your plugins and their ability to clean up after themselves.

      This article was not intended to knock you guys doing your development at no cost – this community has some terrific devs.

      I appreciate the discussion on how to make this platform even better and this just happened to be one of my annoyances with it.

      I have never heard if your plugins so I am going to check them out – thanks.

      • Richard Hay (32 comments.) says:

        Here are all of Hikari’s plugins at the Extend site:

        http://wordpress.org/extend/pl.....idouhikari

      • Hikari (26 comments.) says:

        hehe don’t worry, I wasn’t complaining, just noting my plugins are standardized and do that :P

        And BTW, this feature is still beta, it’s UI isn’t as user friendly as I wanted it to be, and it should support post/comment metadata cleaning too but it doesn’t yet. When I have the time I’m gonna improve it and make it much better, but now with SC2 being released… :)

        Another note, just today I found a “most commented posts” plugin that did exactally what I wanted, but it doesn’t follow widgets standards and because of that its widget appears totally broken… Well I added the feature to 1 of my plugins, soon I’m gonna update it and we’ll have a nice “most commented posts” widget to use!

  9. Len Kutchma says:

    I normally clean out all of the junk manually. As a sidenote, all of Lester’s plugins come with an uninstall/cleanup option.

  10. Andrew@BloggingGuide (90 comments.) says:

    I agree that it should be included in the WordPress extend site. There should really be an option provided to be able to remove database information.

    There are really lots of useful information in these comments. Thank you all!

    • Richard Hay (32 comments.) says:

      Andrew – the community here at WLTC is an awesome collection of folks. The discussions are the best part of the site to hear various views and thoughts.

  11. irma (2 comments.) says:

    Nice, thanks so much for the information. And i think i have to learn more

  12. The cool Guy (4 comments.) says:

    Last month, I also uninstalled an older theme. But the theme was still working and loading some of its contents. Then I cleaned the database and cleared the cache of my web browser, and the older theme was completely finished(uninstalled).

  13. Ajay (11 comments.) says:

    This is one of the biggest drawbacks of WordPress plugins that they don’t cleanup the mess after uninstall. This affects the overall performance.

    I normally login into phpMyAdmin and clean database which are unused.

  14. Nagib (2 comments.) says:

    Hi Richard can you point my a plugin that can be used to delete unused themes and plugins, because currently I am using a free service to hosts my blog, and they don’t give me the ability to delete plugins and themes without ftp accounts, whereas they don’t want to tell me the accounts of the ftp.

    • James (184 comments.) says:

      If WordPress won’t let you delete them directly from the Plugins or Themes section of your Dashboard, you’ll need FTP access. There’s no other way around it.

      It sounds like it’s time for a better hosting provider.

      • Nagib (2 comments.) says:

        Thank you for your response, I will consider move to paid hosting provider, but the problem is since I am unable to access cpanel I can’t download my database files to be uploaded to the new webhosting provider. Anyway thank you.

        • James (184 comments.) says:

          You should still be able to export your contents from Tools -> Export in your blog’s Dashboard.

  15. Erskin Hansen (1 comments.) says:

    How about a “DELETE” option and a “DELETE and UNINSTALL DB OPTIONS”, then if you chose “DELETE” there is a new tab saying “ORPHANS” where you can see a list of Deleted Plugins & Themes who still hold tables/data in the Database; where you would have to option to select them individually and select “UNINSTALL FROM DATABASE”.

    Problem solved.

  16. rounak (1 comments.) says:

    i am facing this problem for my blog, i use to use a plugin name similar post and its size in db is 6gb now i dont know how to clear that please help guys



Obviously Powered by WordPress. © 2003-2013

page counter
css.php