WordPress deactivate a plugin via database?

I have a wordpress script, wp-supercache, that I need to disable (as its cached on a nasty error), however, the error is causing the wp-admin redirect to fail, which means I can’t get into the site to disable the plugin.

Any advice? I can access the database via cpanel.

Related posts

Leave a Reply

10 comments

  1. To disable a specific plugin, you have to remove it from the serialized string that stores the list of all plugins – that’s set in the option_value column of the wp_options table as discussed by @TimDurden. The specific format change you have to make is, taken shamelessly from teh Internet:

    a:4:{
        i:0;s:19:"akismet/akismet.php";
        i:1;s:36:"google-sitemap-generator/sitemap.php";
        i:2;s:55:"google-syntax-highlighter/google_syntax_highlighter.php";
        i:3;s:29:"wp-swfobject/wp-swfobject.php";
    }
    

    That first set of characters – a:4 – designates an array and its length. Note also that each line in the list of plugins has an index. So:

    1. Decrement the index (from 4 to 3 in this case)
    2. In each line, decrement the number after the i:
    3. Remove the specific plugin you want to disable.

    Update the value in the db using the new string you constructed from these steps:

    update wp_options set option_value=<new value> where option_id=<id of this option>
    

    Note that your table name might not be wp_options – you might have a prefix to add.

  2. You only need to rename the folder in /wp-content/plugins/ and the plugin will be automatically de-activated. Once it is de-activated, you will be able to login.

    1. Backup database or just the wp_options table
    2. SELECT option_value FROM wp_options WHERE option_name = ‘active_plugins’;

    3. Copy selected string (serialized string) and paste in the left side at https://serializededitor.com/
    4. Remove the line which plugin you want to deactivate
    5. Copy the serialized result string from the right side and update active_plugins value with it.

      UPDATE wp_options
      SET option_value = ‘THE_NEW_SERIALIZED_STRING’
      WHERE option_name = ‘active_plugins’ LIMIT 1;

  3. I wrote a little exe in .dot to repair/remove options string from database.

    1. Download exe here
    2. Run on MySQL server

    SELECT * FROM wp_options WHERE option_name = ‘active_plugins’;

    1. Paste Results in textbox, press parse.
    2. Remove the ones you don’t want.
    3. Click output, it copies output to clipboard
    4. replace brackets inside the single quotes below with output and Run on MySQL server

    UPDATE wp_options SET option_value = ‘[replace inside single quotes with your output’ WHERE option_name = ‘active_plugins’;

    1. No warranties… I don’t claim to be programmer

    enter image description here

  4. To disable all WordPress plugins on your site:

    1. Login to your database management tool (e.g. PHPMyAdmin)
    2. Execute the following query:

    UPDATE wp_options SET option_value = '' WHERE option_name = 'active_plugins';

  5. Another way to do this is you can backup the site and then just rename the folder of the plugin under /wp-content/plugins/ to some other name . So the plugin will be disabled.
    I wont prefer deleting the plugin folder as it may cause errors.
    After the step is done log in to your wordpress site and delete the plugin from there

  6. Late answer,but answering as it will be useful to someone in the future. All the plugins are stored in the wp_options table in a serialized manner. U can edit this field manually. Or if you unserialize it using a function like in php using unserialize(), you will get an array. just modify it to remove the plugin you want to remove from that array, and serialize it back. then update the table. Thats it. If you want to know more about it here is a good article. It explains all about this.

  7. Using this code you can activate your plugin from the functions.php:

    function activate_plugin_via_php() {
        $active_plugins = get_option( 'active_plugins' );
        array_push($active_plugins, 'unyson/unyson.php'); /* Here just replace unyson plugin directory and plugin file*/
        update_option( 'active_plugins', $active_plugins );
    }
    add_action( 'init', 'activate_plugin_via_php' );