Skip to content

Instantly share code, notes, and snippets.

@glarkou
glarkou / wordpress-change-domain-migration.sql
Last active May 7, 2017 21:40 — forked from chuckreynolds/wordpress-change-domain-migration.sql
Use this SQL script when changing domains on a WordPress site. Whether you’re moving from an old domain to a new domain or you’re changing from a development domain to a production domain this will work. __STEP1: always backup your database. __STEP2: change the ‘oldsite.com’ and ‘newsite.com’ variables to your own. __STEP3: make sure your databa…
SET @oldsite='beta.fxbtrading.com';
SET @newsite='dev.fxbtrading.com';
UPDATE wp_options SET option_value = replace(option_value, @oldsite COLLATE utf8mb4_unicode_520_ci, @newsite COLLATE utf8mb4_unicode_520_ci);
UPDATE wp_posts SET post_content = replace(post_content, @oldsite COLLATE utf8mb4_unicode_520_ci, @newsite COLLATE utf8mb4_unicode_520_ci);
UPDATE wp_links SET link_url = replace(link_url, @oldsite COLLATE utf8mb4_unicode_520_ci, @newsite COLLATE utf8mb4_unicode_520_ci);
UPDATE wp_postmeta SET meta_value = replace(meta_value, @oldsite COLLATE utf8mb4_unicode_520_ci, @newsite COLLATE utf8mb4_unicode_520_ci);
UPDATE wp_revslider_slides SET layers = replace(layers, @oldsite COLLATE utf8mb4_unicode_520_ci, @newsite COLLATE utf8mb4_unicode_520_ci);
UPDATE wp_revslider_slides SET params = replace(params, @oldsite COLLATE utf8mb4_unicode_520_ci, @newsite COLLATE utf8mb4_unicode_520_ci);
/* only uncomment next line if you want all your current posts to post to RSS again as new */