Ever have to move a WordPress site to another server? I know I have. This little SQL script makes the migration just a little bit easier.
Step 1: Replace the occurrences of ‘http://example1.ca/site’ with the URL you’re trying to replace.
Step 2: Replace ‘http://example2.ca/site’ with the new URL
Step 3: Run the script in something like PHPMyadmin
Step 4: Have a coffee, you’re done.
UPDATE wp_options SET option_value = replace(option_value, 'http://example1.ca/site', 'http://example2.ca/site') WHERE option_name = 'home' OR option_name = 'siteurl'; UPDATE wp_posts SET guid = replace(guid, 'http://example1.ca/site','http://example2.ca/site'); UPDATE wp_posts SET post_content = replace(post_content, 'http://example1.ca/site', 'http://example2.ca/site'); UPDATE wp_postmeta SET meta_value = replace(meta_value, 'http://example1.ca/site', 'http://example2.ca/site');
Love this script – I’ve used this thing _so_ many times!