When you’re migrating WordPress (or any other platform using serialized PHP strings in the database) between domains, you must use a safe search and replace method that preserves the integrity of the serialized string lengths. A simple of a dump file for http://localhost to, for example, http://thenewdomain.com is problematic because the length of the string changes but the indexes for the serialized strings does not. Consequently settings are lost and widgets disappear. Not good.
This script can now also handle multiply nested serializations, which can happen in transient values in WP at times, and it can also handle multi-byte Unicode changes safely. This is important now that internationalised domain names are allowed.
It’s Not Only for WordPress
It’s worth mentioning that the code will work for any platform that stores PHP serialized arrays in a MySQL database. You can easily use this script on Drupal, Joomla and many other systems where you need to change items across a database without messing up your stored arrays.
Download Search Replace DB v 2.1.0
Contribute!
A lot of developers now use this plugin. If you feel you can add something, there is now an official Github repository for this script at https://github.com/interconnectit/Search-Replace-DB
Version 2.1.0 (released Dec 2011) Improvements
The latest version 2.1.0 introduced a number of key improvements:
- Added charset support, helping in all sorts of places (thanks Sergey Biryukov!)
- Added option to skip guid column for migrating already live sites
- Removed use of deprecated functions.
- Other bug & comment fixes
Changes being prepared for Version 2.2.0
- Support for BLOBS/Objects to give Drupal compatibility
- Minor tweaks and corrections
github Repo – DRUPAL devs please test master branch!
To see how you can use this tool to aid migrations, check out our article on WordPress migrations or visit the WP Tuts+ article that mentions this script.
If you are in any doubt whatsoever about how to use this plugin, then please consider getting an expert in. It’s a really powerful bit of code that if used badly can damage a WP install beyond repair. If you want help, get in somebody like us, for example, or any of the other great guys listed over at CodePoet.
IMPORTANT: This code is supplied with no warranty or support implied. You use it entirely at your own risk. Currently it is supplied under the WTFPL but this will change to the GPL eventually. And when you’ve finished using the script, PLEASE delete it as it can pose a serious security risk to your site.
Download Search Replace DB v 2.1.0
Changelog:
// Version 2.1.0:
// – Changed to version 2.1.0
// * Following change by Sergey Biryukov – merged in and tested by Dave Coveney
// – Added Charset Support (tested with UTF-8, not tested on other charsets)
// * Following changes implemented by James Whitehead with thanks to all the commenters and feedback given!
// – Removed PHP warnings if you go to step 3+ without DB details.
// – Added options to skip changing the guid column. If there are other
// columns that need excluding you can add them to the $exclude_cols global
// array. May choose to add another option to the table select page to let
// you add to this array from the front end.
// – Minor tweak to label styling.
// – Added comments to each of the functions.
// – Removed a dead param from icit_srdb_replacer
// Version 2.0.0 – returned to using unserialize function to check if string is serialized or not
// – marked is_serialized_string function as deprecated
// – changed form order to improve usability and make use on multisites a bit less scary
// – changed to version 2, as really should have done when the UI was introduced
// – added a recursive array walker to deal with serialized strings being stored in serialized strings. Yes, really.
// – changes by James R Whitehead (kudos for recursive walker) and David Coveney 2011-08-26
// Version 1.0.2 – typos corrected, button text tweak – David Coveney / Robert O’Rourke
// Version 1.0.1 – styling and form added by James R Whitehead
// Version 1.0.0 – original version by David Coveney
To Be Done
Ensure UTF8 encoding is enforced (see comments). Added in v2.1.0
Self/deletion or security system to prevent accidental security risks.
Release CLI version for use on non-WP sites, or for other purposes (already supports use on any MySQL DB.)
Change to GPL V3.
Eliminate warnings and remove deprecated function calls. Added in v2.1.0
Add facility to subscribe to interconnect/it Newsletter.

by
Thanks for hard work and share it!
[...] data which is not easily fixed if you try to do any search and replace. Now there is a way which does that for you but only when you follow those steps to the T. Well, we reckon and hope that the humble [...]