Change WordPress theme via MySQL command line

Posted: 5th August 2013 by kunwardharmesh in WordPress


You may find the list of available themes under ./wp-content/themes folder.

Access MySQL Server from the shell prompt OR Open phpMyAdmin, go to your wp database.

$ mysql
$ use database_name;
$ show tables;

You will see something like this:

 +————+————+————+—————+—————+
 | Tables_in_database |
 +————+————+————+—————+—————+
 | wp_commentmeta           |
 | wp_comments              |
 | wp_links                 |
 | wp_options               |
 | wp_postmeta              |
 | wp_posts                 |
 | wp_term_relationships    |
 | wp_term_taxonomy         |
 | wp_terms                 |
 | wp_usermeta              |
 | wp_users                 |
 +————+————+————+—————+—————+
 11 rows in set (0.00 sec)

Checking current theme:

select * from wp_options where option_name = 'template' or option_name = 'stylesheet' or option_name = 'current_theme';

You will see something like this

 +———–+—————+————–+———-+—————+—————+—————+—————+—————+—————+
 | option_id | option_name   | option_value     | autoload |
 +———–+—————+————–+———-+—————+—————+—————+—————+—————+—————+
 |       149 | current_theme | themename        | yes      |
 |        45 | stylesheet    | themename        | yes      |
 |        44 | template      | themename        | yes      |
 +———–+—————+————–+———-+—————+—————+—————+—————+—————+—————+
 3 rows in set (0.00 sec)

Changing current theme ‘themename’ to ‘twentyeleven’

update wp_options set option_value = ‘twentyeleven’ where option_name = ‘template’ OR option_name = ‘stylesheet’ OR option_name = ‘current_theme’;

Hope you Enjoy!

 

  1. Hi,

    I used this tutorial to solve one problem on my blog https://www.bloggingbook.net

    Thanks