How to disable/enable all wordpress plugin via mysql/shell command lines

In order to view active plugins run:

mysql
use database;
SELECT * FROM wp_options WHERE option_name = "active_plugins";

From shell command line

mysql --host=localhost --user=database_user --password=dbpassword database -e 'SELECT * FROM wp_options WHERE option_name = "active_plugins";'

Save active plugins to file

mysql --host=localhost --user=database_user --password=dbpassword database -e 'SELECT * FROM wp_options WHERE option_name = "active_plugins";' |grep active_plugins |awk '{print $3}' > active_plugins.txt

To disable all plugins run:

mysql

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

[mysql --host=localhost --user=database_user --password=dbpassword database -e 'UPDATE wp_options SET option_value = "" WHERE option_name = "active_plugins";'

Recover all change back:

mysql --host=localhost --user=database_user --password=dbpassword database -e "UPDATE wp_options SET option_value = '`cat active_plugins.txt`' WHERE option_name = 'active_plugins';"

Similar Posts:

Leave a Reply

Your email address will not be published.