How to change WordPress theme via mysql command line

Here I will show you how to change theme of Wordpres site to another

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

mysql
use database;
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';
update wp_options set option_value = 'twentyeleven' where option_name = 'stylesheet';
update wp_options set option_value = 'twentyeleven' where option_name = 'current_theme';

 

Short version:

update wp_options set option_value = 'twentyeleven' where option_name = 'template' or option_name = 'stylesheet' or option_name = 'current_theme';

Below link to download one of default theme

https://downloads.wordpress.org/theme/twentyeleven.2.5.zip

curl -sS https://downloads.wordpress.org/theme/twentyeleven.2.5.zip > temp.zip; unzip temp.zip; rm -f $_

Enjoy

Similar Posts:

    None Found

2 comments on “How to change WordPress theme via mysql command line

Leave a Reply

Your email address will not be published. Required fields are marked *