As of 2017 here are the two best ways I’ve found to handle the transfer of a WordPress database from development to production.
WP Migrate DB Pro
The WP Migrate DB Pro WordPress plugin will let you push, pull, and sync database tables between WordPress installations. This is substantially better than a basic find/replace for many reasons:
- Exports your database as a MySQL data dump (much like phpMyAdmin)
- Does a find and replace on URLs and file paths
- Handles serialized data
- Allows you to save it to your computer as an SQL file
WP Sync DB is a copycat replica of the premium plugin that also exists for free, but I don’t suggest using it. I’m a fan of being paid for the work I do, so I recommend you support Mr. Brad Touesnard and buy a licensed copy of the real thing. WP Sync DB is a replica and is ALWAYS behind in support. I wouldn’t mess around with databases using an unsupported plugin, but that’s just me.
How it works
- Install/activate the plugin on your localhost and production environment
- Configure a push transfer from your localhost/development server to your production
- Fill in rules for which tables to transfer, and define find and replace rules to perform
- That’s it!
InterconnectIT Database Search & Replace Tool for WordPress Databases
The InterconnectIT Database Search & Replace Tool is a free tool and is not a plugin. Instead it’s a stand-alone script that’s installed in the root directory of your WordPress production install. This isn’t as good as WP Migrate DB Pro because it requires a few manual steps, but nonetheless it’s a great option that consistently works.
How it works
- Backup your local database, this is absolutely needed as we’ll be re-importing it soon
- Add the script to a folder in your installs root directory
- Run the find and replace on your database
- Export your database and save it for your production environment
- Re-import your backup from step #1 to restore your localhost
- Connect to your production database and back it up (as you always should before doing these things)
- Import the export we made AFTER running the find/replace routine from step #4
You can use a faster approach, but it involves downtime for your production site which in my opinion is unacceptable. That’s why we call it production, right?