Better Search Replace: A New Plugin for Updating URLs and Text in WordPress Databases

photo credit: Bunches and Bits {Karina} - cc
photo credit: Bunches and Bits {Karina}cc

When migrating a WordPress site to a new domain, you’ll have to update every instance of the site’s URL in the database. Some developers prefer to use tools like WP-CLI or WP Migrate DB to handle this, while others opt for a general database search and replace plugin with a UI in the WordPress admin.

Search and Replace is an old plugin, with nearly a million downloads, that can be used to update URLs and text in the database. I used this plugin successfully for a number of years, but it went without any updates for long time. It has since come under new ownership, although the screenshots demonstrate just how long ago the plugin was released.

Better Search Replace is a new take on database search and replace plugins. It was heavily based on Interconnect/It’s open source Search Replace DB script that performs replacement actions without damaging PHP serialized strings or objects. I’ve used this script a number of times with success, although it’s not as convenient as a plugin. The Better Search Replace plugin packages it up using native WordPress database functions and adds a friendly UI.

better-search-replace-screenshot

The plugin merges the best features from older plugins and the Interconnect/It script to support the following capabilities:

  • Serialization support for all tables
  • The ability to select specific tables
  • The ability to run a “dry run” to see how many fields will be updated
  • No server requirements aside from a running installation of WordPress

Since searching and replacing in the database is a sensitive action to perform, the “dry run” feature gives you a good idea of what you can expect before pulling the trigger. Even with the option of performing a dry run, you will undoubtedly want to have a backup of your database created before touching it.

better-search-replace-dry-run

Migrations aren’t the only reason for this type of plugin. Perhaps you’ve renamed your company or product line and need to replace all instances throughout your website. This plugin makes it safe and easy to perform the replacements directly within the WordPress admin. I tested it on a development site and found that it is fast and works exactly as advertised.

Better Search Replace was created by Matt Shaw, author of the Revisr plugin that allows developers to synchronize WordPress with a remote Git repository. If you’re a long-time fan of the Interconnect/It script, you’ll find that this plugin is even easier to use. You can find Better Search Replace on WordPress.org.

11 Comments


  1. Timesaver, just changed domain for one web and starting changing pictures urls in database … Then remembered that I read today something here :D so install it fast and easy changed about 60 urls with few clicks. Much better than do it one by one :D
    Thanks to developer for great plugin and thanks to Sarah, that posted about it here.

    Report


  2. I’ll definitely have to take a look at this, could be very helpful when guiding a client through this sort of process. I’m curious how it works with migrations though. Usually if you’ve moved a site to another domain, you’re unable to access the WP Admin. It will redirect to the URL in the database when attempting to login. This being a plugin accessed from within the admin, I don’t see how it’s possible to use for URL replacement.

    Report


  3. Search and Replace is not the one linked to, and according to the developer, Frank Bülgte, it has not been sold. The plugin was also updated as recently as September last year. The plugin should work just as well now as it did during the WordPress 2.5 days (when the screenshots are from).

    Or was it perhaps a different plugin being rerferred to and not the Search and Replace plugin?
    https://wordpress.org/plugins/search-and-replace/

    At any rate, Frank seems to think the new plugin is a good idea anyway … https://twitter.com/bueltge/status/553233728181637120

    Report


  4. I have tried this plugin, but when doing a dry run it gave me a white screen and didnt do anything. I was really hoping this would work. The theme im using on a site isnt working correctly and I need to change some urls.

    Report


  5. Thanks. After using Interconnect.it’s script for a few years it’s sort of a relief someone took the time to turn it’s functionality into a plugin! Your post helped me discover this and for that I’m grateful :-)

    Report

Comments are closed.