Changing Old URL’s in Website Database After Migration
Are you unsure of how to update the outdated URLs in the database when you wish to move your WordPress website to a new URL? With its free migration option, hostvento provides hassle-free URL hosting.Additionally, here is a guide for you if you choose not to go through the laborious manual process of updating the URLs!
We’ll get to know the easy ways to update the URL of your WordPress website.
Introduction
There are times when you want to migrate your WordPress website to a new URL. You don’t just need to update the website URL. Rather you also need to update the URLs in the database that includes the different MySQL database tables.
If you have a considerably small website, it’s possible to update the URL manually. But, if you have a large website with huge data, it’s not possible to update the old URL manually. Also, changing the URLs in bulk on the website is a very time-consuming process, and while doing this, you may even miss out on updating some of them.
Finding automated solutions like doing mass searches and replace of old URL’s is essential in these scenarios. In this article, we will take a look at some of the easy ways to update the site’s URL when migrating a WordPress website.
When Should You Update WordPress Website URLs?
Here are some of the common scenarios that let you update the old URLs in the database.
- Migrating a WordPress website to a new web server
- Move from HTTP to HTTPs
- Shifting website from one domain to another domain on the same web server
- Change the directions of WordPress on the existing server
When updating the URL of the website, you need to make sure that some additional aspects also need to be taken care of with changing the URL on the settings page. If the images do not have external CDNs, the links to the old URL will be embedded in the posts.
Furthermore, it appears that every time someone visits the page, these links break. It is a good idea to manually change two or three URLs on a tiny website. However, it can be difficult to update every image on a large website or blog. You must devise an automated method for bulk URL replacement in the database.
Ways To Change the Old URL’s in Database
The first thing you need to do before changing the URLs is that you need to take a complete backup of your WordPress database. If there’s any mistake or anything goes wrong, you can take back the changes again.
You can do the manual backup of the database or take advantage of the free WordPress plugins. Let us now get to know the different methods for changing the WordPress site URLs.
Updating the Website URLs Manually- For small websites
You can choose to manually update all of the URLs on a tiny website by hand.Frequently, you should search for content and simply modify any instances where you have links to the home page and other internal pages. This approach can be used if your website is small or one page, as it will save you money by not having to install plugins on it.
Change the URL in the Database
While changing the URLs, you will face some issues frequently like:
Old URLs in the Widgets and Menus:
- The old URL exists not only in posts but also in the menus and widgets.
- Broken Images and Video Links: If you have replaced the URL of your website, sometimes it may happen that the images do not function properly. This can even lead to issues with the page display if you do not update the image URLs.
The URLs are stored in different database tables, and you can change them manually.
The URLs for the custom menu are present in the meta-value field in the wp_postmeta table. And the image URLs are present in the posts_content field in the wp_posts table. For the old link manager, the image URL’s are present in the link_inage fields in the wp_links fields
You need to first make sure what to replace. Places where you will be able to find the URL on your website.
- Inside the posts and pages: “posts_content” field in the “wp_posts” table.
- Old link manager: “link_url” and “link_image” filed which are present in the “wp_links” table
- Custom Menu URLs: “meta_value” field present in the “wp_postmeta” table
- Themes and plugins: “option_value” field in the “wp_options” table
- URLs present in the comment section: “comment_content” field in the “wp_comments” table
You can update the database in the URL by changing the above tables and fields.
Using PHPMyAdmin Script for Search and Replace in Database
With MySQL, you can execute raw queries both to find, replace and use it to update the URL database. This is one of the ideal ways to change the URLs if you have a very big website that needs several changes.
Updating Links with MySQLYou can utilize the MySQL replace command to search and replace the text which is inside the database tables.To update the URL, you need to run the query given below over different tables and fields.
update TABLE_NAME set FIELD_NAME = replace(FIELD_NAME, ‘find string’, ‘replace string’);
Then, open the PHPMyAdmin panel and go to log in.
Click on the WordPress database
To replace the URL’s across all the database tables, click on the SQL tab and type the code given below:
UPDATE wp_options SET option_value = replace(option_value, 'Existing URL', 'New URL') WHERE option_name = 'home' OR option_name = 'siteurl'; UPDATE wp_posts SET post_content = replace(post_content, 'Existing URL', 'New URL'); UPDATE wp_postmeta SET meta_value = replace(meta_value,'Existing URL','New URL'); UPDATE wp_usermeta SET meta_value = replace(meta_value, 'Existing URL','New URL'); UPDATE wp_links SET link_url = replace(link_url, 'Existing URL','New URL'); UPDATE wp_comments SET comment_content = replace(comment_content , 'Existing URL','New URL');
If you are having the images linked to your posts, then you need to also run the additional queries:
If you have images inside the posts:
UPDATE wp_posts SET post_content = replace(post_content, 'Existing URL', 'New URL');
For images linked in the old manager:
UPDATE wp_links SET link_image = replace(link_image, 'Existing URL','New URL');
If you have images linked as attachments
UPDATE wp_posts SET guid = replace(guid, 'Existing URL','New URL');
- All the queries given above run for default tables known for having the URL entries in WordPress.
- Just click on the Go button
- The existing URL would be updated to site wide to a new URL.
Updating the Old URLs in the Database using WordPress Plugins
If you are not able to update the URLs by running the MySQL queries, then you have another option of doing it with the WordPress plugins. These plugins let you update the old URL’s in the database.
Here are some of the plugins which will help you to update the old URL’s in the database:
Search and Replace Plugin
You may search and replace the text on your blog or website using the WP-Admin interface provided by the Search and Replace plugin. A basic search or “search and replace” can also be done.
Here, you can enter the previous URL in the search field and then swap it out for the current one. You will be prompted to edit the title and content; make the appropriate selection.
Also, you have to check the posts or the pages box, and then click on Go!

Better Search Replace Plugin
It’s one of the plugin to update the URL’s in WordPress database. It lets users to replace the URL within all or just a few database tables.

Velvet Blues Update URLs
You can modify the URLs at various points, such as pages, articles, and so forth, with the Velvet Blues Updates URL plugins. Both the old and new URLs for your website must be entered.
After then, you need to select where the URL of your website needs to be updated.

WP Migrate
WP migrate is basically a WordPress migration plugin that makes the it easy to export and migrate your database.
The migration takes place like:
First, find the replace the data you want from the WP migrate interface


Conclusion
WP site owners many times need to change the URL of their WordPress website. The entire process of changing the old URLs in the database is quite lengthy and requires a lot of patience if it’s done manually.
For small websites and blogs, performing a basic search and replace will often be the most effective method. To alter the website’s picture and URL, it is advisable to utilize the “serialize-data sensitive” search and replace tool or plugin. When migrating a website and replacing its URL with the new one, these tools would be quite beneficial. I hope you found this essay useful! Ask experts for help if you are still unclear about how to change the URLs on your WordPress site.