How To Change or Update WordPress URLS in Mysql Database

How To Change or Update WordPress URLS in Mysql Database When Site is Moved to new Host.

 

 

 

 

 

 

Assumption:
OLD WORDPRESS URL: http://www.oldurl.org
NEW WORDPRESS URL: http://www.newurl.org
WORDPRESS DATABASE: wordpress

Execution:


mysql> use wordpress;
mysql> UPDATE wp_options SET option_value = replace(option_value, 'http://www.oldurl.org', 'http://www.newurl.org') WHERE option_name = 'home' OR option_name = 'siteurl';
mysql> UPDATE wp_posts SET guid = replace(guid, 'http://www.oldurl.org','http://www.newurl.org');
mysql> UPDATE wp_posts SET post_content = replace(post_content, 'http://www.oldurl.org', 'http://www.newurl.org');
mysql> UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://www.oldurl.org','http://www.newurl.org');

In the above mysql commands you need to change wordpress database name, old url and new url only, the rest is as it is.



Donate Bitcoin
Leave a Reply

Your email address will not be published. Required fields are marked *