Web Design

Better Search Replace plugin to replace strings in DB in WordPress.

DB内の文字列を検索・置き換え「Better Search Replace」

Hi there.
I’m Satou, a Web/App/UI designer.

This time, I will write about Better Search Replace, a plugin that allows you to replace strings in DB in WordPress.

Replacement of URLs is required when using Xserver’s working URLs.

The other day, I had an opportunity to use Xserver’s working check URLs for a project.
After creating a WordPress website and setting up the nameservers for the domain, I used it as a confirmation environment until it was reflected.

“Xserver’s Operation Confirmation URL” is a service that issues a temporary URL called “http://domain-name.check-xserver.jp/” to check the operation of your website until your domain name server settings are reflected.

It was fine up to that point, but after that, when the name server settings were reflected and the website could be accessed with the domain name, it became a hassle.

The WordPress site URL setting had become a working URL.
All the URLs WordPress outputs, including permalink URLs and admin URLs, have become working check URLs.
Of course, all the media URLs are also in the URLs to be confirmed.

Xserver's working URL
Xserver’s URLs are not of the nature of duplicating sites or redirecting accesses, but rather they seem to be temporary but actually assign a URL to check the operation of the site, which can be set in the WordPress settings screen. )” and “Site Address (URL)” in the WordPress configuration screen.

Therefore, you can access the website by entering the domain name directly, but when you move to other pages after that, the URL will be the confirmation URL.
Also, if you right-click on the image and open it in a new tab, the URL will be displayed in the address bar of your browser.

Therefore, we have to rewrite every possible string “http://domain-name.check-xserver.jp” in the DB to “http://domain-name”.

When you place media on a fixed page or post in WordPress, the img tag is written with the full path starting from https:// (or http://).
Changing “WordPress Address (URL)” or “Site Address (URL)” from the settings page will not change these descriptions, so you need to replace the strings in the DB.

Try “Better Search Replace” plugin for replacing strings in DB

I’m sure many of you have been using “Search Regex” when it comes to string replacement plugins in DB in WordPress.
I am one of them, but “Search Regex” was last updated one year ago, and its operation has not been tested on the latest WordPress.
This is not good.
So I decided to use a string replacement plugin other than Search Regex.

If you search for “database replace” in the WordPress add plugin screen, you will find several plugins.
Among them, I decided to use “Better Search Replace”.
The reason is as follows.

  • It appeared first in the search results.
  • Last updated 2 months ago and relatively new.
  • More than 1 million active installations and many users.
  • It had a high rating of 4.5 with 455 ratings.
search for 'database replace'

Run “Better Search Replace”.

Now, let’s use “Better Search Replace” to replace the working URL string in the DB with the official URL.
Better Search Replace” is available in the “Tools” menu of the Administration menu.

BetterSearchReplace Run it from 'Tools' in the menu

Easy to use

Using “Better Search Replace” is easy.

  • String to search.
  • String to replace the searched string.
  • DB table to search.

and execute it.

Run 'Better Search Replace'

When executed, the progress bar will extend and

Run Replace with

Done immediately.

Run Replace with

You can see how many replacements were made in which table.

Run Replace with

Some options as you see fit

Options include

  • Case sensitive or not
  • whether to rewrite the GUID.
  • Whether to run a dry run.

Please select as appropriate.

Whether to be case-sensitive.

Please decide accordingly.

Whether to rewrite GUIDs.

You can leave this unchecked.

GUID stands for Globally Unique IDentifier.

A 128-bit random number that is guaranteed to be unique and not duplicated anywhere in the world. It is used in object-oriented systems to identify objects.

Insider’s Computer Dictionary:What is GUID? – @IT


This string doesn’t have to contain a separate URL, but WordPress requires the URL to be included.

There is no particular disadvantage to not rewriting this, and on the contrary, rewriting it may cause some kind of problem, so let’s leave it alone.

Whether to run a dry run (rehearsal).

Use your judgment accordingly.
When run, it will tell you how many strings to search for and in which table.

Better Search Replace Rehearsal Run-1 Better Search Replace Rehearsal Run-2

Search and Replace with Regular Expressions Available in Paid Version

Search and replace using regular expressions is not available in the free version.
If you want to perform more elaborate replacements, you will need to purchase the paid version or consider another plugin.

The paid version has four plans, some with the ability to migrate media files, and some with the ability to migrate theme files and plug-ins as well.
This may be useful for website duplication and server migration.

Simple and easy to use “Better Search Replace”

I was going to try several string replacement plugins in DB before deciding, but the first one I tried, “Better Search Replace”, was so simple and easy to use that I think I’m done with it.

  • Case sensitive or not
  • Whether to rewrite GUID.

I think that the “Better Search Replace” option is safe and secure, so I think I’ll continue to use “Better Search Replace” from now on.

If you have any other plugin recommendations, I would appreciate it if you could let me know via Twitter.

Well, this time, I wrote about Better Search Replace, a plugin that can replace strings in DB in WordPress.
How was it?
I’m glad if it was helpful for you who read it.
See you next time.