Find and Replace URL In WordPress Database

Find and Replace URL In WordPress Database sometimes the webmaster needs to change the WordPress URL in the database. It could be due to either migration to another domain name, moving to another subdirectory, or the use of an SSL certificate.

Find and Replace URL

It is easy for small websites to do it manually, but it is quite difficult for large sites. It is a time-consuming process if you do it manually, and there is a risk of missing URLs. Webmasters have to find and replace hundreds of URLs in the database tables as well as in SQL database tables.

However, there are a few other things that webmasters must have to consider while changing or updating the old URLs.

For example, if the images on the website don’t use CDN, the old links of images are added automatically in the posts with a new or updated URL. As a result, the links of images are shown as broken links when a visitor visits the webpage.

Ways To Find And Replace URL In WordPress Database

Ways To Find And Replace URL In WordPress Database

There are different ways that you can use to find and replace the URL in the WordPress database either manually or by using a plugin. We will discuss all the possible methods in the below section. Just take a look at them.

Search and Replace in phpMyAdmin

It is easy to find and replace the URL by using phpMyAdmin. But it is somehow tricky, and you need to know little about coding. If you don’t know about coding, just follow the below-mentioned steps to change the URL in different tables of the database.

For this purpose, log in to your Cpanel and go to phpMyAdmin. There you can find different tables on the right sidebar, and you have to make changes to different tables one by one.

WP Options

wp_options: In this tab, you can find the WordPress configuration table that consists of a site URL for home and fields. You can use the following code to find and update the URL.

UPDATE wp_options SET option_value = replace(option_value, '', '') WHERE option_name = 'home' OR option_name = 'siteurl';

WP Posts

wp_posts: This table consists of the content of all posts in the post_content field. It is important to update URL table because if you have internal links in your posts, you have to replace the old URLs. Otherwise, it will be shown as broken links.

UPDATE wp_posts SET post_content = replace(post_content, '', '');

WP Post meta

wp_postmeta: In this table, you can find all the attributes and custom fields along with advanced custom fields (ACF). If there are any permalinks in custom fields, you must have to replace them with the new one by using the following code.

UPDATE wp_postmeta SET meta_value = replace(meta_value, '', '');

WP Comments

wp_comments: This table comprises post comments, and this table may include some permalinks to other posts on your website. Therefore, don’t forget to update this table and use the following code line to update it.

UPDATE wp_comments SET comment_content = replace(comment_content , '', '');

Change the links to images

There are various images that you use in the posts on your websites. As we mentioned above, it is important to change the links of images to avoid broken link errors in the posts. The following are the few types of images URL that you have to change.

Use the below-mentioned coding line for images used inside the posts.

UPDATE wp_posts SET post_content = replace(post_content, 'Existing URL', 'New URL');

If you have images that are linked with the old link manager, then use the following code.

UPDATE wp_links SET link_image = replace(link_image, 'Existing URL','New URL');

Use the following code for images used as attachments.

UPDATE wp_posts SET guid = replace(guid, 'Existing URL','New URL');

WordPress Plugins Find and Replace URL

Various WordPress plugins are available to facilitate webmasters. These plugins are useful to find and replace URLs in the WordPress database. Plugins are also beneficial to avoid the risk of missing any URL from replacement. In the below section, we will discuss the two top-rated plugins.

Search & Replace Plugin

Search & Replace is an open-source WordPress plugin designed by a group of professional plugin developers. It helps webmasters to search and replace anything in the database of the WordPress website. For example, you can search and replace the URL, text, etc. by using this plugin.

The primary purpose of this plugin is to avoid mistakes that are usually practiced by the users while updating the URL. It also offers users to replace the URL or domain quickly and even complete the entire migration process in a few minutes.

Moreover, this plugin provides complete support for serialized data that is helpful for both developers and WordPress users. It allows the users to update the entire URLs with a single search and replace command.

The easy-to-use enables the users to make it one of the most popular plugins to update the URL. You can easily use this plugin from the following steps:

Follow the following steps to do it via the WordPress plugin:

Step # 1: Go to plugins in the WordPress dashboard.

wordpress dashboard

Step # 2: Click add new button

add new plugin in wordpress

Step # 3: Find the “Search add and replace URL” plugin

wordpress search and replace plugin

Step # 4: After installation and activation go to Tools > Search & Replace

search and replace

Step # 5: Provide the new URL that you want to replace with the old one.

change wordpress url

Here you can complete the entire process with a single command or can select the specific tables where you want to change.

You can change the entire domain in the database with a single command, as mentioned in the image.

search and replace domain

You can change the URL in the specific tables under the search and replace the tab, as mentioned in the image.

search and replace url under specific table

Migrate WordPress Database: (WP Migrate DB)

WP Migrate DB is another WordPress search and replaces a plugin widely used by WordPress users to migrate and export the database in an easy, simple, and quick way. It offers many useful features like backup before any changes, provides support for the command line, and many more.

The best part of this plugin is that it offers support for targeted database migration. By using this feature, users can select that include or exclude the tables for migration purposes. It also provides support to push and pull different files of plugins and themes as well as media libraries from one site to another.

It is easy to handle the migration of serialized data and arrays and allows the users to complete the entire process without any chances of errors.

The following are the steps following the below-mentioned steps to install and complete the changing process.

Step # 1: Go to plugins in the WordPress dashboard.

Step # 2: Click add new button

Step # 3: Search for WP Migrate DB

wordpress db migrate

Step # 4: Adjust the setting as described in the image and the export button at the bottom to start the changing process.

wordpress database mirgation - migrate DB

Important Note:

If you select to update the data manually, make sure that you understand the consequences that you may have to face if it goes wrong. Therefore, you must make sure to take the backup of the database so that you can reverse the process in case of error.


Every webmaster or website owner may need to change the URL due to any reason. Therefore, it is essential to understand the basics of migration to handle the situation securely.

Hopefully, you enjoy the above discussions and get a lot of benefits.

See More

Redirect HTTP To HTTPS htaccess to WordPress

What Is Incoming Mail Server Hostname


Flash Sale

Hurry Up! Offer ends in
02 days
21 hrs
46 mins
59 secs
Buy Now