Changing your WordPress domain name URL
When you have to migrate a site from one URL to a new domain name, the following SQL commands will help you out.
These can be run from the CLI or PHPMyadmin as a standard SQL statement.
UPDATE wp_options SET option_value = replace(option_value, ‘olddomain.com’, ‘newdomain.com’) WHERE option_name = ‘home’ OR option_name = ‘siteurl’;
UPDATE wp_posts SET guid = replace(guid, ‘olddomain.com’, ‘newdomain.com’);
UPDATE wp_posts SET post_content = replace(post_content, ‘olddomain.com’, ‘newdomain.com’);
UPDATE wp_postmeta SET meta_value = replace(meta_value, ‘olddomain.com’, ‘newdomain.com’);
As a side note, you will probably have to change every instance of your website home directory too if this has changed. eg, /home/oldsite would become /home/newsite. You can modify the above commands to perform this for you.
This entry was posted in Computer
and tagged SQL
. Bookmark the permalink