How To Change or Update WordPress URLS in Mysql Database

Like it? Share it
Tweet This Share on Facebook Share on Google Plus Pinterest linkedin

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.

End of line.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  Subscribe  
Notify of