Update a wordpress site to a new domain…
I like to do all my work locally, and so I frequently copy a remote site to my local computer, but I also like to NOT mess with my hosts file so that I can always look at the live site, and you never get into one of those “Is this the live site?” situations.
It is easy to do this, just run the following queries on the mysql database that wordpress is on, and edit the wp-config.php file to point to the new domain.
update wp_options set option_value=REPLACE(option_value, 'old_domain', 'new_domain');
update wp_site set domain=REPLACE(domain, 'old_domain', 'new_domain');
update wp_sitemeta set meta_value=REPLACE(meta_value, 'old_domain', 'new_domain');
update wp_blogs set domain=REPLACE(domain, 'old_domain', 'new_domain');
Categories: Uncategorized