Skip to content

Instantly share code, notes, and snippets.

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 robinnorth/5386677 to your computer and use it in GitHub Desktop.
Save robinnorth/5386677 to your computer and use it in GitHub Desktop.
WordPress: Prepare database for production environment
# Update options
UPDATE wp_options SET option_value = REPLACE( option_value, 'staging.com', 'production.com' );
# UPDATE wp_options SET option_value = REPLACE( option_value, 'admin@staging.com', 'admin@production.com' );
# Update inline images
UPDATE wp_posts SET post_content = REPLACE( post_content, 'staging.com', 'production.com' );
# Update image attachment GUID
UPDATE wp_posts SET guid = REPLACE( guid, 'staging.com', 'production.com' ) WHERE post_type = 'attachment';
# Update custom fields
UPDATE wp_postmeta SET meta_value = REPLACE( meta_value, 'staging.com', 'production.com' );
# Update post GUID
UPDATE wp_posts SET guid = REPLACE( guid, 'staging.com', 'production.com' );
# Change post author
# UPDATE wp_posts SET post_author = 'new-author-id' WHERE post_author = 'old-author-id';
# Update Multisite
# UPDATE wp_site SET domain = REPLACE( domain, 'staging.com', 'production.com' );
# UPDATE wp_sitemeta SET meta_value = REPLACE( meta_value, 'staging.com', 'production.com' );
# UPDATE wp_blogs SET domain = REPLACE( domain, 'staging.com', 'production.com' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment