phpMyAdmin Find and Replace by SQL Query

We need to move websites to whole new domain names. We frequently need to manually modify the URLs in order to rectify them because WordPress maintains all information in databases. Or you want to replace a link that is found thousands of times on your entire site with another link.

We frequently use the phpMyAdmin find and replace function for this purpose. It is a procedure that automatically searches a database for a word and swaps it out for another. Today, let’s talk in depth about this approach.

Why is this Find and Replace necessary?

If we need to replace many terms in a database, the phpMyAdmin find and replace tool is really helpful.

We can quickly modify a URL, an image, or even a paragraph on the website by using this option.

In order to replace the old domain data in the database with the new ones, we primarily select this option following the Website Migration. Let’s practice finding and replacing some words.

Method 1: Find and Replace by SQL Query in phpMyAdmin

We execute a SQL Query using phpMyAdmin to find and replace text. Here are the steps we take:

  • Initially, we click on the website’s database in phpMyAdmin after opening it.
  • Next, we enter the following query by selecting SQL from the toolbar and clicking on the new window.
update TABLE_NAME set FIELD_NAME = replace(FIELD_NAME, 'Text to find', 'text to replace with');

Then, click on the Go button to continue.

Find and replace in phpMyAdmin

The number of rows affected by the query is displayed by phpMyAdmin after the query has successfully executed.

Method 2: How to phpMyAdmin find and replace?

Using phpMyAdmin, perform a find and replace as follows:

1. Start by logging into cPanel.

2. Next, select phpMyAdmin.

3. Next, choose Database from the list.

4. The tables of the chosen database will be listed on the right-hand side. The table in which we want to perform the search and replace operation is selected after that.

5. After that, select the Search link at the top.

6. Next, select Find and replace from the top menu.

Find and replace in phpMyAdmin

7. Next, we enter the string we wish to change in the Replace with area and a new string in the Find section.

8. The values listed below are in the Column option.

option_name
option_value
autoload

Click Go after choosing each column value from the drop-down menu.

Note: Due to the way the Plugin functions, we cannot alter every column in a database at once. The columns must be chosen one at a time.

When the Find and Replace plugins are not functioning, this is a decent alternative.

Before starting a find and replace, our engineers always make a database backup.

Conclusion

In summary, we went through in detail how to use phpMyAdmin’s Find and Replace function to quickly replace terms in the database after a migration or in any other situation.

Related Posts