If you have a blog that is up for few years already and suddenly you decided to move to a new domain / url, you end up changing all the link from config, to post contents and to comments. Using a few MySQL command, you can restore your blog and change all the links to the new domain.
Here are the steps I did when I moved from lysender.co.cc to blog.lysender.com. Using phpMyAdmin, we need to update all links to all related tables and its fields using this basic syntax:
UPDATE target_table set target_field = REPLACE(target_field, 'http://lysender.co.cc', 'http://blog.lysender.com');
where target_table is the table you want to update and target_field is the field that may contain the links you want to update. REPLACE there is a MySQL function that replaces instances of string. The first parameter is the target field, second is the string to find, and the third is the string that will replace found string.
These are the common table / fields that is going to be affected as of WordPress 3.0:
- wp_config: option_value
- wp_posts: post_content
- wp_comments: comment_author_url
- Others I forgot to write here
So for example I want to update all my post content links such as link to my other articles, url to an image or url to a certain demo or resource, all I need to do is execute this command on phpMyAdmin:
UPDATE wp_posts set post_content = REPLACE(post_content, 'http://lysender.co.cc', http://blog.lysender.com');
However, it is still helpful if we will manually check the database contents to ensure (at least) that no stray links left.