Sync Two MySQL Databases
Matthew Harrington
What is a good way to sync two MySQL databases?
I would like to sync the data in my production website's database to my local development database. Right now, I am just using the PHPMyAdmin interface to export it from one, and then I import it into the other.
These would be user-initiated sync's, not necessarily periodic or automated (something like a one-click sync).
24 Answers
Here are a couple of ideas:
- Use Replication:
- Use mysqldump in an import/export script to semi-automate it
SQLyog Enterprise and Ultimate can do this.
SQLyog has a free version although it cannot do the syncing operations unfortunately. The paid versions start at $69 but a 30-day trial is available. For a free solution, replication is your best bet as quickcel outlined, although it requires a bit of configuration.
It now also has feature called 'Visual Data Compare' where data can be compared and synched visually.
1For a free and reliable one-off MySQL synchronization tool, check out Percona Toolkit (formerly Maatkit):
0SQLYog's SJA tool (free for Linux) can do this brilliantly and I have used it for years and years already. All it takes is an XML file generated with the correct login info, your database and tables desired. I could not have done without it.
1