Renaming your Wordpress 2.x blog to another domain name

Thanks to mydigitallife for the hints on how to do this.

In my case bilbo.some.net was renamed to kinscoe.somenewplace.com.


UPDATE wp_options SET option_value = replace(option_value, 'http://bilbo.some.net',
'http://kinscoe.somenewplace.com') WHERE option_name = 'home' OR option_name = 'siteurl';

UPDATE wp_options SET option_value = replace(option_value, 'http://bilbo.some.net',
'http://kinscoe.somenewplace.com') WHERE option_name = 'home';

UPDATE wp_posts SET guid = replace(guid, 'http://bilbo.some.net','http://kinscoe.somenewplace.com');

UPDATE wp_posts SET post_content = replace(post_content, 'http://bilbo.some.net', 'http://kinscoe.somenewplace.com');

show tables;
+---------------------------+
| Tables_in_bilbo_wordpress |
+---------------------------+
| wp_categories             |
| wp_comments               |
| wp_link2cat               |
| wp_links                  |
| wp_options                |
| wp_post2cat               |
| wp_postmeta               |
| wp_posts                  |
| wp_usermeta               |
| wp_users                  |
+---------------------------+
10 rows in set (0.02 sec)

SHOW FIELDS FROM wp_options;

+---------------------+------------------+------+-----+---------+----------------+
| Field               | Type             | Null | Key | Default | Extra          |
+---------------------+------------------+------+-----+---------+----------------+
| option_id           | bigint(20)       |      | PRI | NULL    | auto_increment |
| blog_id             | int(11)          |      | PRI | 0       |                |
| option_name         | varchar(64)      |      | PRI |         |                |
| option_can_override | enum('Y','N')    |      |     | Y       |                |
| option_type         | int(11)          |      |     | 1       |                |
| option_value        | longtext         |      |     |         |                |
| option_width        | int(11)          |      |     | 20      |                |
| option_height       | int(11)          |      |     | 8       |                |
| option_description  | tinytext         |      |     |         |                |
| option_admin_level  | int(11)          |      |     | 1       |                |
| autoload            | enum('yes','no') |      |     | yes     |                |
+---------------------+------------------+------+-----+---------+----------------+
11 rows in set (0.04 sec)

select option_value from wp_options WHERE option_name = 'home';
+---------------------------+
| option_value              |
+---------------------------+
| http://bilbo.some.net |
+---------------------------+
1 row in set (0.01 sec)

Note that in this case I was only renaming the virtual host not actually moving the site to another server. If you do that then you also need to backup your database and restore it to the new server as well.

Leave a Reply

You must be logged in to post a comment.