Skip to content

Instantly share code, notes, and snippets.

@cranca
Last active April 10, 2020 09:45
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 cranca/0214acb66c99789b6ae1a3c9dbab0044 to your computer and use it in GitHub Desktop.
Save cranca/0214acb66c99789b6ae1a3c9dbab0044 to your computer and use it in GitHub Desktop.
Plantilla de comandos para cambiar las URL de una BBDD de WordPress
/*
IMPORTANT:
This gist asume that your table's prefix is wp_ if not, prefix must be replaced for the correct one
*/
UPDATE wp_options SET option_value = replace(option_value, 'http://oldurl', 'http://newurl') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'http://oldurl','http://newurl');
UPDATE wp_posts SET post_content = replace(post_content, 'http://oldurl', 'http://newurl');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://oldurl','http://newurl');
/*
IMPORTANT:
This gist asume that your table's prefix is wp_ if not, prefix must be replaced for the correct one
*/
/* WPMS UPDATE */
UPDATE wp_site SET domain = replace(domain,'http://oldurl','http://newurl');
UPDATE wp_sitemeta SET meta_value = replace(meta_value,'http://oldurl','http://newurl') WHERE meta_key = 'siteurl';
UPDATE wp_blogs SET domain = replace(domain,'http://oldurl','http://newurl');
/* options and posts UPDATE */
UPDATE wp_options SET option_value = replace(option_value,'http://oldurl','http://newurl') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid,'http://oldurl','http://newurl');
UPDATE wp_posts SET post_content = replace(post_content,'http://oldurl','http://newurl');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://oldurl','http://newurl');
/* repeat for each subsite */
UPDATE wp_1_options SET option_value = replace(option_value,'http://oldurl','http://newurl') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_1_posts SET guid = replace(guid,'http://oldurl','http://newurl');
UPDATE wp_1_posts SET post_content = replace(post_content,'http://oldurl','http://newurl');
UPDATE wp_1_postmeta SET meta_value = replace(meta_value,'http://oldurl','http://newurl');
/* Don't forget this!!!
define('DOMAIN_CURRENT_SITE','new-domain');
define('PATH_CURRENT_SITE','/');
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment