Plugin: Database Search & Replace

Plugin: Database Search & Replace

Extremly detailed article on manually searching and replacing.

Search-replace from command line

If you can install WP-CLI, superior way is to use WP-CLI search-replace command.

I have used a PHP CLI script called Search-Replace-DB and I am quite satisfied. Read about it here.

This is how you install it

cd /var/www/vhosts/hostingtipp.ch
wget https://github.com/interconnectit/Search-Replace-DB/archive/master.zip
unzip master.zip && rm master.zip && mv Search-Replace-DB-master srdb
chmod a+x srdb/srdb.cli.php

And use it with

cd /var/www/vhosts/hostingtipp.ch
srdb/srdb.cli.php --dry-run -h localhost -u hostingtipp-ch -p "S06d7#mw" -n hostingtipp-ch -s "http://www.hostingtipp.ch/wp-content/" -r "/wp-content/"

Search-replace with a plugin

Sometimes I need to do a lot of replacement, so a nicer way is needed - as a Wordpress plugin. So decided to do a research on this.

The same Search-Replace-DB script is converted to a plugin and is found under the name Better Search Replace. Read more details about it here.

Also very flexible is Search Regex, but it doesn’t search in wp_options table and probably not in any unknown plugin table, because it does not support serialized data.

Note: This is almost perfect plugin. Just read more here

The most famous one is Search and Replace but it’s incredible how shitty it is.


  • The Replace Contents plugin performs search and replace on HTML content and is authored by my favorite Japanese minimalist developer.

A Quick CSS Fix for the “Search Regex” Plugin

It bothers me that the highlighted text match has extra padding. In fact, I often have situations where it’s crucial to see whether there’s a space character or not, and the padding confuses me, a lot! I suggest removing that padding, and while we’re at it, I made my small correction in the CSS styles that I believe are better than the default.

1
2
3
4
5
6
.searchregex-result__deleted, .searchregex-result__highlight, .searchregex-result__replaced {
  font-weight: unset;
  padding: 0;
  background-color: #f2f75d80;
  outline: 10px solid #f2f75d80;
}

Feel free to add this CSS to your admin panel and there are many plugins that can help you with this. If you have no idea which plugin to use, use Add Admin CSS for example.

date 17. Aug 2016 | modified 29. Dec 2023
filename: Plugins » Database & SQL » Search & Replace