WordPress DB migration from one domain to another

Usually I develop WordPress powered sites on my server and then migrate all to production one.

Every time I have the same problem – name of old server is saved in DataBase various tables.

It is possible to simplify the process.
1. execute domain name replacement in General settings

update wp_options set `option_value` = replace(`option_value`, 'olddomaine.com', 'newdomain.com') where instr(`option_value`, 'olddomaine.com') > 0

Usually, there is not so many occurrences, but there might be more than 2.

2. replace any links to old domain url in your posts.

update wp_posts set `post_content` = replace(`post_content`, 'olddomaine.com', 'newdomaine.com') where instr(`post_content`, 'olddomaine.com') > 0

Number of lines to be changed depends on how many pictures and inner links you inserted in the post on old server.

NOTE: backup you DB before such activities.

Leave a Reply

%d bloggers like this: