Skip to content

Instantly share code, notes, and snippets.

@brendonexus
Forked from thiagoeliasr/change-wp-url.sql
Created October 9, 2018 08:30
Show Gist options
  • Save brendonexus/aecdc9bb794c7cea0c8e0e94a656f6b5 to your computer and use it in GitHub Desktop.
Save brendonexus/aecdc9bb794c7cea0c8e0e94a656f6b5 to your computer and use it in GitHub Desktop.
Change Wordpress URL via SQL
UPDATE wp_options SET option_value = replace(option_value, 'http://www.oldurl', 'http://www.newurl') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'http://www.oldurl','http://www.newurl');
UPDATE wp_posts SET post_content = replace(post_content, 'http://www.oldurl', 'http://www.newurl');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://www.oldurl','http://www.newurl');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment