Posts Tagged ‘mysql’

How to change wordpress theme directly from database?

January 9, 2010 |  by Mukesh Chapagain  |  3 Comments
c9745a19ff357e71def843760f0c71d5 Del.icio.us

I had some error in my new wp theme. When I enabled the new theme, I got a blank page. I was unable to access my wordpress blog both from frontend and backend (admin panel).

In this case, either I need to change/fix my theme’s code. But, what if I am not a coder?

The solution is to change the currently active theme from database.

Open phpMyAdmin, go to your wp database. Open wp_options table. Search for three option_nametemplate, stylesheet, and current_theme.

SELECT *
FROM wp_options
WHERE option_name = 'template'
OR option_name = 'stylesheet'
OR option_name = 'current_theme';

See the option_value fields from the search result. The option_value will be your theme name. Change option_value of the search result to ‘classic’ OR ‘default’. Classic and default are the default wordpress themes present at the time of wp installation.

UPDATE wp_options SET option_value = 'default' WHERE option_name = 'template';
 
UPDATE wp_options SET option_value = 'default' WHERE option_name = 'stylesheet';
 
UPDATE wp_options SET option_value = 'default' WHERE option_name = 'current_theme';

How to transfer wordpress installation from one server to another?

December 27, 2009 |  by Mukesh Chapagain  |  2 Comments
b2ab1778ce8e28fa1cefc8bb884d0fab Del.icio.us

Suppose, you are migrating you wordpress installation from one server to the other. In this case, you might have a different database server, database username and password. You might also have a different domain name as well. A general scenario will be migrating you wordpress installation from your localhost (local installation on your computer) to any online server.

In this case, you need to consider few things to make the site working. You need to make changes in wp-config.php (present in root directory of wordpress installation) and some update in wp-options table of your database.

Changes in wp-config.php

I suppose that my database name is wordpress, database username is root, password is pass and database server name is localhost.

/** The name of the database for WordPress */
define('DB_NAME', 'wordpress');
 
/** MySQL database username */
define('DB_USER', 'root');
 
/** MySQL database password */
define('DB_PASSWORD', 'pass');
 
/** MySQL hostname */
define('DB_HOST', 'localhost');

Changes in database (wp-options table)

1) In wp-options table, search for siteurl and home in option_name column.

SELECT * FROM `wp_options` where `option_name` = 'siteurl' OR `option_name` = 'home';

2) Then edit the option_value column for the two rows with your current site url. I have supposed your current url as http://example.com. You can put your own url.

UPDATE `wp_options` SET `option_value` = 'http://example.com' WHERE `wp_options`.`option_name` = 'home' ;
 
UPDATE `wp_options` SET `option_value` = 'http://example.com' WHERE `wp_options`.`option_name` = 'siteurl' ;