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 landsman/7e3741abd384f1606009cf02770cda9a to your computer and use it in GitHub Desktop.
Save landsman/7e3741abd384f1606009cf02770cda9a to your computer and use it in GitHub Desktop.
WordPress change domain query
SET @old_domain = 'http://olddomain.com';
SET @new_domain = 'http://newdomain.com';
UPDATE wp_options SET option_value = replace(option_value, @old_domain, @new_domain) WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = REPLACE (guid, @old_domain, @new_domain);
UPDATE wp_posts SET post_content = REPLACE (post_content, @old_domain, @new_domain);
UPDATE wp_postmeta SET meta_value = REPLACE (meta_value, @old_domain, @new_domain);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment