Moving a WordPress database
Here is a simple SQL statement to run on a WordPress database to move it from one domain name to another
/* // Simply change the 2 variables below. // If your blog runs over HTTPS you will also need to change this in the last 2 lines. */ SET @oldDomain = 'www.olddomain.com.au'; SET @newDomain = 'www.newdomain.com.au'; update wp_posts SET guid = REPLACE(guid, @oldDomain,@newDomain) WHERE guid REGEXP @oldDomain; update wp_posts SET post_content = REPLACE(post_content, @oldDomain,@newDomain) WHERE post_content REGEXP @oldDomain; update wp_postmeta SET meta_value = REPLACE(meta_value, @oldDomain,@newDomain) WHERE meta_value REGEXP @oldDomain; update `wp_options` set option_value = concat('http://',@newDomain) WHERE option_name = 'siteurl'; update `wp_options` set option_value = concat('http://',@newDomain) WHERE option_name = 'home';
Edited by Andrew on 18/01/2013: Optimised SQL