Several of our readers have asked us how to do a bulk find and replace in WordPress without having to do it all manually.
We understand the challenges of managing a large WordPress site with tons of content. Whether you’re migrating from an old domain, rebranding, or simply fixing a typo, manually searching and replacing content in every post, page, and comment is nearly impossible.
Fortunately, you can easily search and replace text, URLs, and images on your WordPress site using the Find and Replace WordPress plugin or a simple SQL query.
In this article, we will show you how to find and replace text in your WordPress database.
When Do You Need to Find and Replace in Your WordPress Database?
In some cases, you may need to find and replace items in your WordPress site's database.
For example, you added specific text or URLs to some of your posts. You don't know in which posts you added this text, but you know there are a lot of such posts.
Now, you could manually search your site and edit each post one by one. But this would take a lot of time, and there’s a high chance that you’ll miss some text that you wanted to change.
Automatically finding and replacing items with a single command will perform the same operation, but faster and more efficiently.
There is a downside to this method, though. If you make a mistake, you can't undo it. The replaced text will disappear. You need to carefully enter the text you want to find and the text you want to replace it with.
That being said, let’s see how to easily find and replace text in your WordPress database.
Before running a search and replace on the database
As we mentioned before, the changes you make to the database are irreversible. You need to be very careful to ensure that you do not lose data.
First, you need to create a backup of your WordPress database. You can do this using a WordPress backup plugin like Duplicator.
It’s a great tool that lets you create backups in just a few clicks. To learn more about its features, check out our Duplicator review .
Alternatively, you can also use phpMyAdmin to create a database backup .
After creating the WordPress database backup, you can proceed with running the find and replace command.
Run a Find and Replace with a WordPress Plugin
If you are not familiar with code and do not want to write custom SQL queries, there is an easy to use find and replace WordPress plugin called Search and Replace Everything.
We have thoroughly tested this tool and it works great. You can read more about our experience with it in our Search and Replace Everything review.
First, you need to install and activate the free Search and Replace All Content plugin. See our WordPress plugin installation guide for more details .
NOTE: There is also a premium version of Search and Replace Everything with more advanced features.
Upon activation, visit Tools » WP Search & Replace page in your WordPress admin dashboard.
Here, enter the text you want to change in the “Search” field. Then, you must enter the text you want to replace it with in the “Replace with” field.
You can also select specific tables in your WordPress database or select all of them.
Next, press the “Preview Search and Replace” button.

The plugin now allows you to review the changes it makes before applying them.
Then, just click the Replace All button.

Run a "Find and Replace MySQL Queries" using phpMyAdmin
You can also use phpMyAdmin to find and replace text from your WordPress database.
First, you need to log in to the dashboard of your WordPress hosting account. For this tutorial, we will be using Bluehost .
Once there, click on the “Website” option in the left sidebar and switch to the “Advanced” tab.
After that, scroll down to the ‘PHPMyAdmin’ section and click on the ‘Manage’ button next to it.
This will open phpMyAdmin in a new window.
Here, you have to click on your WordPress database name and then click on “SQL”.
You will then need to enter your SQL query in the following format:
update TABLE_NAME set FIELD_NAME = replace(FIELD_NAME, 'Text to find', 'text to replace with');
For example, if you wanted to search for text within the content of a WordPress post, then you would write your query like this:
update wp_posts set post_content = replace(post_content,'Text to find','text to replace with');
Then, click the Go button to continue.
phpMyAdmin will run your SQL query, and upon success, it will display the number of rows affected by the query.
You can now visit your WordPress site to see the changes in action.
Bonus: Easily Optimize Your WordPress Database
Once you have replaced the required text in the database, we recommend optimizing it to remove the unnecessary data and improve the performance of the database.
To do this, you can install and activate the WP Optimize plugin. For more information, see our WordPress plugin installation tutorial .
Upon activation, visit the WP-Optimize page from your WordPress dashboard . You will see a list of actions that the plugin will perform on your database. You can review these actions and uncheck any items that you currently do not want to run.
Here you can optimize your database tables, clean up post revisions, draft posts, and more. After that, just click on the “Run on all selected items” button at the top.
The plugin will now optimize your database for you. However, if the process is interrupted, your data may become corrupted. Therefore, we recommend that you create a backup of your website before optimizing.
For more information, see our tutorial on how to optimize your WordPress database .
We hope this article helped you learn how to find and replace text in your WordPress database with one click. You may also want to check out our beginner’s guide on managing your WordPress database with phpMyAdmin .
If you liked this article, you can also share it on Twitter and Facebook.
Disclosure: Some of the links in this article contain affiliate links, which means we may earn a commission if you click through to visit us, at no extra cost to you. See how SidelinePlay is funded, why it’s important, and how you can support us.
Was this helpful?