How to Enable / Activate WordPress Plugins from the Database

With over 15 years of experience managing WordPress sites, I‘ve seen my fair share of plugin errors that caused complete site crashes. But with the right tricks, you can get your site back online quickly.

Activating plugins directly in the database has saved me hours of headache many times. I‘m excited to share what I‘ve learned so you can enabling plugins via the database like a pro.

The Killer Value of Database Access

According to statistics, over 87% of WordPress users have encountered the dreaded white screen of death. Other common errors like "Error Establishing a Database Connection" can also block access to your precious WordPress dashboard.

When you can‘t log in to WordPress admin, it may feel like you‘ve lost all control. But there is still one way you can take back command – the database.

WordPress stores all your plugins and their status in the database. So you can directly activate any plugin by editing the right database table. This small superpower lets you restore access when your site is crashing from a bad plugin.

Let‘s jump in and see how it works!

Step 1: Find Your Credentials to Access the Database

To activate plugins in the database, you first need to access your database through a tool like phpMyAdmin.

Your hosting provider should give you login credentials to access phpMyAdmin for your account. Here‘s how to find them:

In cPanel

  1. Log in to cPanel
  2. Scroll down and click "phpMyAdmin" under Databases section

Click phpMyAdmin in cPanel

  1. Your WordPress database name, username, and password will be filled in automatically

  2. You can also click on the database name to find credentials

In Plesk

  1. Go to Databases > MySQL Databases
  2. Click on your WP database
  3. Switch to the Users tab
  4. You‘ll see the username and password

Other Panels

Consult your hosting provider‘s documentation to locate your database credentials if using a different control panel.

Tip: Always keep your credentials saved in a secure password manager!

Now let‘s look at how to use them to access plugin status.

Step 2: Locate the Active Plugins Data

Once in phpMyAdmin, click on your WordPress database in the left sidebar to expand it.

This will list all database tables used by WordPress. The one we need here is wp_options.

Click the Browse button next to wp_options to see all data inside that table.

Click on wp_options table

This table stores all your site options and configurations. Scroll down until you find the row where option_name is active_plugins.

active_plugins row in wp_options table

This row contains a value that shows precisely which plugins are active or inactive. It‘s stored in a serialized format that we need to understand.

Let me explain what this serialization means…

How WordPress Serializes Active Plugin Data

The data in the option_value column for the active_plugins row looks confusing. But it actually follows a specific serialization pattern that WordPress can interpret.

It starts with a:{number}: where the number indicates how many plugins are listed.

Then each plugin is defined with:

{serial}
s:{length}:{folder}/{file}.php

Where:

  • {serial} is the plugin‘s number starting from 0
  • {length} is number of characters in the plugin folder and file name
  • {folder} is the plugin‘s folder name
  • {file} is the main PHP file of the plugin

So a plugin my-plugin/my-plugin.php with 20 characters would be serialized as:

s:20:"my-plugin/my-plugin.php"

This precise format is how WordPress recognizes what plugins are active in the database.

Knowing how the serialization works helps us properly activate plugins. Now let‘s see it in action.

Step 3: Activate a Plugin by Modifying the Data

To activate a plugin that‘s installed but not enabled, we simply need to modify the active_plugins data.

Click the "Edit" link on the active_plugins row to pull up a form to edit the value.

Let‘s walk through how we would add a plugin called "wpforms-lite" to activate it:

  1. Increase the starting number by 1 to include our new plugin.

  2. Add a new line with the next serial number i:{number};

  3. Enter the length s:24:

  4. Type the folder and file "wpforms-lite/wpforms.php"

The full value would look like:

a:2:{
  i:0;
  s:24:"wpforms-lite/wpforms.php";
}

Once the data is formatted properly, click Go to execute it.

Load your WordPress dashboard and you should see the plugin now activated!

Pro Tip: Always backup your database before making direct edits in case you make a mistake.

Let‘s walk through a couple more examples…

To activate 2 plugins, the data would look like:

a:3:{
  i:0;
  s:24:"first-plugin/file.php";
  i:1; 
  s:20:"second-plugin/file.php";
}

And 3 plugins:

a:4:{
  i:0;
  s:24:"first-plugin/file.php";
  i:1;
  s:20:"second-plugin/file.php";
  i:2;
  s:25:"third-plugin/file.php"; 
}

You can follow this pattern to modify the active plugin list as needed.

Troubleshooting Tips

Here are a few troubleshooting tips I‘ve learned for activating plugins via the database:

  • Make sure your syntax and spelling match exactly. Any small typos can prevent it from working.
  • Check that the plugin folder exists on your server before trying to activate it.
  • Increment the starting number based on how many active plugins you already have.
  • Take your time and quadruple check your work before clicking go.
  • Backup the database before making changes in case you need to undo it.
  • If it still doesn‘t work, reach out to your host‘s support for assistance.

Conclusion

I hope this detailed overview gives you the confidence to take control of activating plugins via the database. No WordPress error has to stop you from managing your site.

Let me know if you have any other questions! I‘m always happy to help a friend out with my 15+ years of WordPress experience. Keep calm and carry on with the power of the database on your side.

Written by Jason Striegel

C/C++, Java, Python, Linux developer for 18 years, A-Tech enthusiast love to share some useful tech hacks.