The WordPress Database Problem
One of the biggest challenges with WordPress development is keeping your local and live databases in sync. When editing a WordPress theme, I find it easier to have a real time copy of the live site database so that I am working with real content.
Another challenge is keeping a development site synced with up a local database. I make content changes and updates to the local site for speed reasons, but then I have to get those changes to the development site somehow so the client can see them.
The previous solution has been to log into phpMyAdmin, make a backup of the database, log into the development site, replace the existing database, and then do a find and replace of the site URLs. This is both time consuming and cumbersome.
How to Sync A WordPress Database
Thankfully, I have found a great solution. The WordPress plugin WP Migrate DB Pro has an amazing feature that lets you pull and push site databases, similar to how version control works.
Here’s how I use it to sync databases between my local WordPress database and development WordPress database.
1. Install the plugin on both my local and dev sites.
2. Enter the license key on both sites.
3. On both sites, under the Settings tab, check the box for accept pull requests and accept push requests.
4. Copy the generated Connection Info API key from the dev site.
5. On the local site, under the Migrate tab, choose Push.
This will replace the remote database (dev site) with the local dataase.
6. Paste the Connection Info API key into the textarea and click Connect.
I usually have to change the protocol from ‘https://’ to ‘http://’ manually for it to work. If you get a time out error, just click Connect again.
7. Use the find and replace feature to change the URLs in the database so they work on your development site.
8. Click Migrate DB. After a couple minutes (depending on the size of your database) the databases will be in sync!
Download WP Migrate DB Pro
I started using the plugin a couple months ago and it has already more than paid for itself in the amount of time it has saved me. Download it here.
I just purchased this recently and agree it is fantastic for moving the entire DB (or selected tables) from one location to another. However, it will completely overwrite the tables on the receiving end…which is tricky if you have, say, a client adding content to a remote site while you’re developing on your local server. I’m looking for a practical strategy/solution to sync DBs in a way that merges (or version control) the changes between them. Have you come across any good ideas or have any thoughts regarding this?
Hi Jacob,
There is another solution by Crowd Favorite called RAMP that I believe does just that.
Thanks, Jeremy…that does look promising.