How to update database url by using sql query in phpmyadmin?

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.

database-url-query

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.

Cheers

13 thoughts on “How to update database url by using sql query in phpmyadmin?”

  1. 2
    3
    4
    5
    6
    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’);

  2. This is great information for students. This article is very helpful i really like this blog thanks. I also have some information relevant for online dissertation help.

  3. Much obliged for setting aside an ideal opportunity to talk about that, I feel unequivocally about this thus truly like becoming acquainted with additional on this sort of field. Do you psyche overhauling your blog entry with extra understanding? It ought to be truly helpful for every one of us.

  4. Good website! I truly love how it is easy on my eyes it is. I am wondering how I might be notified whenever a new post has been made. I have subscribed to your RSS which may do the trick? Have a great day!

  5. Thanks for sharing this quality information with us. I really enjoyed reading. Will surely going to share this URL with my friends.

  6. I have as of late begun a website, the data you give on this webpage has helped me extraordinarily. Much obliged for the greater part of your time and work. Questions to Ask

  7. Eminently composed article, if just all bloggers offered the same substance as you, the web would be a far superior spot.. Hero Instinct

  8. Extraordinary article Lot’s of data to Read…Great Man Keep Posting and redesign to People..Thanks His Secret Obsession Review

  9. Goodness! This could be a standout amongst the most valuable websites we have ever go over on thesubject. Really amazing information! I’m likewise a specialist in this theme so I can comprehend your exertion. Love quotes

  10. Thanx for sharing such useful post keep it up 🙂

  11. I’m really impressed with your article, such great & usefull knowledge you mentioned here

  12. Thanks for the sharing this great article related to The Future of the Web.. this article is very usefull for me.Thanks again for sharing this great article! five nights at freddy’s

  13. Thank you for providing this useful information

Leave a Reply to Hero Instinct Cancel reply