This past weekend I had a WordPress website migration to make.
It wasn’t your traditional migration, as the domain changed. With well over 500 blog posts, it wasn’t a small move, but I did learn a few things that I would like to share with you all.
After importing the old database info into it’s new place, I went ahead and changed the WordPress settings via MySQL (maybe will cover this more later). I thought I was done, until I realized that all internal links were wrong. From images to URLs, the blog was essentially broken.
Knowing that I could run some MySQL magic and update all of these in one routine, I hit-up Google on the deets.
Here’s what I learned:
“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 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.”
Serialized PHP Search & Replace Tool
This was ridiculously awesome.
Not only did this update everything the correct way, it was quick and easy!
Here’s what I did:
- Downloaded Search Replace DB v2.1.0 (a simple PHP file)
- Renamed it with a cryptic name
- Uploaded it to my root WordPress install (the usual httpdocs)
- Jumped to my browser and dialed it in: http://newurl.com/crypticname.php
- Followed the prompts
- Ska-DOOSH! <– (the sound I made in my head when it finished)
- Deleted the crypticname.php file from the server
And that’s it!
All the internal URLs and image file links were updated and now correct. Plus, I had the security that the strings in the database were not harmed in any way.
Pretty cool, right?