When we are building site in WordPress there is very important thing is it’s database. When you are moving your website to new host it is very important to change database url also. Changing url in file is very important when we import sql file in phpmyadmin. so there are two steps to do it. first one is by using your code editor and another one is to run sql query. Below Steps will show to the easiest way to change url in database.
Run sql query in phpmyadmin
In the new host after importing sql file in phpmyadmin you just have to run sql query which shown below and you’r done.
UPDATE wp_options SET option_value = replace(option_value, 'http://www.oldsiteurl', 'http://www.newsiteurl') WHERE option_name = 'home' OR option_name = 'siteurl'; UPDATE wp_posts SET guid = replace(guid, 'http://www.oldsiteurl','http://www.newsiteurl'); UPDATE wp_posts SET post_content = replace(post_content, 'http://www.oldsiteurl', 'http://www.newsiteurl'); UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://www.oldsiteurl','http://www.newsiteurl');
Once you run this query your database url update with the new url. See this screenshot which helps you more.
This is the first method from which you can directly replace a url by using sql query in phpmyadmin. Now lets move on to the another method.
Replace old url with new by using code editor
This method is very easy to perform for this you need a code editor. You just need to open sql file in code editor and just replace all the old urls with the new url. Once all the urls is replace you have to import that sql file is in new host and you are done.
Be careful when you are replacing old urls with new you have take care about every symbols and characters specially for newbies. So hope this article may useful for you also if you have any question or comment about this article. you can contact us anytime or comment below.