WordPress Database Files Replacement

Find and replace plugin or a simple SQL query. We will show you how to find & replace text in your WordPress database using files replacement

By Claudio Pires
Updated on December 25, 2022
WordPress Database Files Replacement

Are you looking to do a mass search and replace the WordPress database? Whether you want to find and replace a specific text, URL, or image, you can easily do so by using a find-and-replace WordPress plugin or a simple SQL query. This article will show you how to find and replace text in your WordPress database using files replacement.

Searching On WordPress Database

Typically, there’s no way to search and alter your WordPress database from within your dashboard. That’s by design because the DB is the nerve center of your website. Everything is up there, from usernames, and emails, to the web address and WooCommerce API keys and tokens. The DB is important. And being able to edit it all willy-nilly is dangerous.

Usually, it would help if you edited database tables through a tool like phpMyAdmin. In general, you can find this in the cPanel of your host under, you guessed it, databases. Once inside, you have an array of options and tables and numbers and tabs and…well, you can see for yourself.

Those to the left are databases for your host, generally representing one WP install each. And then, when you click on one of those, you see all the options you have for all the different kinds of data. And now, you hit Search, and you see the data in that table. Now you can start with the finding and replacing.

That’s a…lot. And it is really easy to get out and completely turned around like this. So, the Better Search and Replace plugin may be a good answer for you if you need to edit, change, or migrate any data in your database. This is where our free and easy plugin solution comes in! As a result, a good reason to use WordPress Database files replacement.

WordPress Plugin

When you install the plugin from the WordPress plugin repository, you get a new settings menu that appears under Tools called Better Search Replace.

This new addition offers a much friendlier user interface than phpMyAdmin. And the best part is that this plugin limits the database to this WordPress installation. So there are no fears of affecting any other sites. There are three main things here to pay attention to.

Replacing

Pretty straightforward. Whatever values you’re looking for will be up here, no matter which table (or how many). For instance, if you edit all comments containing the name of a particular website you don’t want to be present, you can enter the website name in the first field, and the redaction would go in the second.

Selecting Tables

Depending on the depth and breadth of your search, you can choose which tables you want to alter. For instance, if you are only looking to alter the comments areas, you can select the ones labeled with comments and comments met with a CTRL/CMD click.

Running

I think this is the most crucial option they give you. Since the database is so sensitive, performing a dry run gives you a simulation of what would happen. Just enter your info and keep this check to get a report on which tables and fields will be changed. It is imperative (if you ask me) to do this first before you make any permanent changes to your site. As a result, a good reason to use WordPress Database files replacement.

Using the Plugin

Using the plugin itself is simple. For example, I will walk you through changing a WordPress administrator username. Yes, the same kind of username as admin or has a warning beside it in the profile that says it can’t be different. This kind of use-case for DB manipulation makes Better Search and Replaces shine.

First off, you can see the list of users for the WP site.

I aim to change Nolan Sorento’s username from The Top Dawg to IOI-655321. By doing so, he will log in using the replacement, and anywhere the username was used on the site will also be replaced.

I highlight all the tables with a CTRL/CMD click, enter my search and replace terms in the fields, and make sure I do a dry run first.

As you can see, the only instances of the original username were in users and usermeta tables. Perfect. Now, uncheck the dry run and perform the real search and replace. Afterward, you will see in the banner that the cells were updated, which is verified in the modal, too. Additionally, you can see that instead of .001 seconds, the operation tool is 0.004 and 0.003 seconds, so you can tell there was actual computation happening behind the scenes.

When we go back to the Users page, you can see the change has taken hold, and the username is entirely new.

You can even go into the user and see that the greyed outfield has been changed. Usernames cannot be changed, huh? I’ll show you WordPress documentation!

Final Words

I think that’s a much nicer, more elegant way of working with your WordPress databases. You can use this for any number of changes that you want to make, including web addresses (changing all file locations away from localhost. dev to elegantthemes.com, for instance).

Understanding and working with the WordPress database is essential for you to grow as a developer (and, I’d say, a user, too). But some of the tools out there are pretty intimidating. Hopefully, Better Search and Replace has shown you there’s no reason to be intimidated.

Claudio Pires

Claudio Pires is the co-founder of Visualmodo, a renowned company in web development and design. With over 15 years of experience, Claudio has honed his skills in content creation, web development support, and senior web designer. A trilingual expert fluent in English, Portuguese, and Spanish, he brings a global perspective to his work. Beyond his professional endeavors, Claudio is an active YouTuber, sharing his insights and expertise with a broader audience. Based in Brazil, Claudio continues to push the boundaries of web design and digital content, making him a pivotal figure in the industry.