WordPress migrations are a major part of the WordPress Management Service we offer at Bobcares.
We sometimes receive requests to migrate websites to a completely different domain name. Because WordPress stores all details in databases, we often need to edit the URLs manually to correct them.
This is where the “Find and replace” option in phpMyAdmin comes in handy. It is a process that automatically looks for a word in a database and replaces it with another.
Let us discuss this method today in detail.
Why do we need this Find and replace?
The “Find and replace” option in the phpMyAdmin is very useful if we need to replace multiple words in a database.
Using this option,, we can change a website’s URL, image, or even text in less time.
We chose this option mainly after the Website Migration to replace the old domain data in the database with the new ones.
Let’s see how we perform this Find and replace.
How do we Find and replace using phpMyAdmin?
The steps to do a find and replace using phpMyAdmin are:
1. Initially, log in to the cPanel.
2. Then click on phpMyAdmin.
3. After that, click on the Database.
4. On the right, the tables of the selected database are listed. Then, we click on the table where we want to perform the search and replace process.
5. Next, click on the Search option at the top.
6. After that, click on the “Find and replace” button on the top.
7. Then we provide the string that we want to replace in the Find section and a new string in the Replace with section.
8. The Column option contains the below values.
option_name
option_value
autoload
Then select each column value from the dropdown list and click Go.
Note: We cannot replace all columns in a database at once as the Plugin works. We have to select the column in a one-by-one manner.
This is a good option when the Find and Replace plugins are not working.
If we only want to replace values for specific rows, we can add additional conditions in the WHERE clause.
Furthermore, the REPLACE function is case-sensitive, so Example.com and example.com will be treated as different strings.
If we’re using regular expressions, be careful to avoid unintended consequences. A poorly constructed regular expression can lead to unexpected results.
Our engineers always perform a database backup before proceeding with finding and replacing.
It is very important to always back up your database before running a bulk find-and-replace operation. Mistakes can be challenging to undo, especially if they affect a large amount of data.
Find and Replace by SQL Query
We use phpMyAdmin to find and replace text by running an SQL Query. Here, we follow the steps:
- Initially, open the phpMyAdmin and click on the website’s database.
- Then, in the new window, we click on SQL from the toolbar and write the query below.
update TABLE_NAME set FIELD_NAME = replace(FIELD_NAME, 'Text to find', 'text to replace with');
- Finally, click on the Go button to continue.
After the query ran successfully, the phpMyAdmin shows the number of rows affected.
[Need more assistance with Find and replace in phpMyAdmin? Click here to talk to our experts.]
Conclusion
In short, we discussed in detail the Find and replace in phpMyAdmin for replacing the words in the database easily after migration or any other scenario.
Thank you very much
Hello,
Thank you for your feedback! We are delighted to hear that our article was helpful to you.