Uncategorized Change wordpress site url using mysql query

This tutorial is a very important part of moving WordPress site to one host to another host or localhost to live web hosting.
Here i am trying to elaborate the best basic method that is required to deploy WordPress site to live hosting.
So i can say there are some MySQL replace queries that will search the given string and then replace matched string to string that need to be changed .
Basically this MySQL query will use wp_option, wp_posts, wp_postmeta,wp_user and wp_usermeta.
So you can use this query in phpmyadmin sql console.

UPDATE wp_options SET option_value = replace(option_value, 'http://siteoldurl', 'http://sitenewurl') WHERE option_name = 'home' OR option_name = 'siteurl';

UPDATE wp_posts SET post_content = replace(post_content, 'http://siteoldurl', 'http://sitenewurl');

UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://siteoldurl','http://sitenewurl');

UPDATE wp_posts SET guid = replace(guid, 'http://www.siteoldurl','http://sitenewurl');

UPDATE wp_usermeta SET meta_value = replace(meta_value,'http://www.siteoldurl','http://sitenewurl');

Please note : Please do not forget to change “http://www.siteoldurl” and ” http://sitenewurl” with correct url and please be careful about the “wp” prefix because sometime php developer or wordpress installation software use different prefix for mysql table.
So you can check MySQL table prefix from wp-config.php.
This can be found using this variable.
$table_prefix = ‘wp_’;

Author Details