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
Wow didnt know you could do this. WIll definelty try and implement it in the future when transferring databases across domains.
This is a great little script. I had been using something similar, but this one is a bit more optimised.
Cheers guys.
@Grant & @Kane - I'm glad it's been useful for you. We use it all the time.
Awesome. Love your work. Thanks Ben!