Skip to content

Instantly share code, notes, and snippets.

@jseidl
Created August 2, 2012 17:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jseidl/3238715 to your computer and use it in GitHub Desktop.
Save jseidl/3238715 to your computer and use it in GitHub Desktop.
Wordpress Migration
$old_site = 'http://example.com';
$new_site = 'http://newsite.com';
$wpdb_prefix = 'wp';
# Replace slugs
update ${wpdb_prefix}_posts set guid = replace(guid, $old_site, $new_site);
# Replace title, excerpt and content
update ${wpdb_prefix}_posts set post_title = replace(post_title, $old_site, $new_site);
update ${wpdb_prefix}_posts set post_excerpt = replace(post_excerpt, $old_site, $new_site);
update ${wpdb_prefix}_posts set post_content = replace(post_content, $old_site, $new_site);
# Update site url
update ${wpdb_prefix}_options set option_value = '$new_site' where option_name ='home';
update ${wpdb_prefix}_options set option_value = '$new_site' where option_name ='siteurl';
# For serialized data
http://interconnectit.com/124/search-and-replace-for-wordpress-databases/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment