Easiest Way to Search And Replace a WordPress Site

If you’ve ever been in charge of moving a WordPress website, you know it can get daunting making sure everything moved over correctly (especially if it’s your first time). However I would like to introduce a tool that makes moving WordPress website 100 times easier, which is aptly named Search Replace DB (by interconnect/it). What makes this tool very special is its ability to search and replace text, while keeping serialized fields formatted properly.

The Issue

If you aren’t sure what serializing is or why it would matter in the context of searching and replacing, I will give a simple overview. Serializing data is very, very useful. It allows us to store data from variables into a database and quickly grab them, reverse the serializing and left with the same value we began with. If we start with the text value ‘hunter’, then serialize it we get the result:

s:6:"hunter";

You should still see our hunter text however you should notice the text “s:6:”, this indicates the value is a string (other values that can be used are integer, boolean, Null, array and object) that is 6 characters long. Now if we were to change the text manually to just “hunt” we would get a value that looks like this:

s:6:"hunt";

But when PHP reads the value it will fail as the string character count is no longer 6.

The Solution

Cue Search Replace DB, when searching through the database fields with this tool it will first unserialize the value, replace your text (in most cases the new URL for your website) then re-serialize and update the value. This process may seem a tad complex for just simply replacing database values, however due to the nature of serializing (covered above) this is required so that we don’t lose any website data.

The tool uses separate AJAX actions to search and replace for the values so in most cases you won’t need to worry about increasing server specifications.

Search Replace DB

Before providing the link to this tool I must first warn about the dangers of leaving this tool on your server, if someone were to stumble upon it they can quickly and easily hack the website and delete/modify any and all data. As soon as your are done with search and replacing you should immediately delete these files.

And now without further adieu, Search Replace DB.

If you should have any troubles with migrating your website please don’t hesitate to contact us.