Posted By

brownrl on 05/12/15


sql wordpress migrate

Versions (?)

Migrate a Wordpress

 / Published in: SQL


Moving a wordpress site for local dev, to staging, to production? This SQL snippet has done the job more often than not. It may not be 100% full proof but it has saved my butt hundreds of times. Please, if you know other tables or enhancements share them.

  1. SET @from_host = '';
  2. SET @to_host = '';
  3. UPDATE `wp_commentmeta` SET `meta_value` = REPLACE(`meta_value`, @from_host, @to_host);
  4. UPDATE `wp_comments` SET `comment_author_url` = REPLACE(`comment_author_url`, @from_host, @to_host);
  5. UPDATE `wp_comments` SET `comment_content` = REPLACE(`comment_content`, @from_host, @to_host);
  6. UPDATE `wp_icl_strings` SET `value` = REPLACE(`value`, @from_host, @to_host);
  7. UPDATE `wp_icl_string_positions` SET `position_in_page` = REPLACE(`position_in_page`, @from_host, @to_host);
  8. UPDATE `wp_icl_translation_status` SET `translation_package` = REPLACE(`translation_package`, @from_host, @to_host);
  9. UPDATE `wp_links` SET `link_url` = REPLACE(`link_url`, @from_host, @to_host);
  10. UPDATE `wp_options` SET `option_value` = REPLACE(`option_value`, @from_host, @to_host);
  11. UPDATE `wp_postmeta` SET `meta_value` = REPLACE(`meta_value`, @from_host, @to_host);
  12. UPDATE `wp_posts` SET `guid` = REPLACE(`guid`, @from_host, @to_host);
  13. UPDATE `wp_posts` SET `post_content` = REPLACE(`post_content`, @from_host, @to_host);
  14. UPDATE `wp_site` SET `domain` = REPLACE(`domain`, @from_host, @to_host);
  15. UPDATE `wp_sitemeta` SET `meta_value` = REPLACE(`meta_value`, @from_host, @to_host);
  16. UPDATE `wp_usermeta` SET `meta_value` = REPLACE(`meta_value`, @from_host, @to_host);
  17. UPDATE `wp_wprc_repositories` SET `repository_logo` = REPLACE(`repository_logo`, @from_host, @to_host);

Report this snippet  

You need to login to post a comment.