19

I have two identical MySQL databases one in an internal server and the other in a web hosting server. I want to update the database on the web host each day with the database on the internal server. Is there a way to automate this process also how can I do this manually? If I'm to do it manually, does it require me to get a SQL dump of the Database on the internal server and then import it on the database on the web host? Can someone advice please.

  • You can refer existing answer posted here in StackOverflow stackoverflow.com/questions/52583/… – Mahesh Patil May 22 '14 at 10:02
  • about #2 if i do full dump from internal and import on production it would overwrite the online database, i mean i have online buyers on database web hosted and i want to migrate the internal database buys into live , can you please clarify BTW what will happen to auto increaments between two if they both were reserving same id it will be messy rigth !? – shareef May 6 '18 at 16:04
21

You have a few options:

  1. Set up MySQL replication between the servers. Your internal server can act as the Master, and the web host server as the slave. Any updates performed on the Master will be replicated to the slave immediately (assuming a working connection). This will most likely be the easiest and most effective option to choose. To use replication, your internal database would need to be accessible over the network from the web host.

    You can read more about replication here.

  2. Each day, you can perform a mysqldump on the internal server, upload the dump file to the web host, and import the data. Since this is a full dump, if you have a very large database, this might not be feasible. If you like, this procedure could potentially be scripted to avoid having to do it manually.

  3. You can set up binary logging on the internal server. You can then ship the binary logs to the web host and apply them to the database, effectively playing all transactions that occurred that day to the web server. In effect, this is what happens with replication anyway, so you would nearly always go with the replication set up instead of this option.

If there is no connection between the two databases, taking mysqldumps each day will be the easiest path to take.

  • about #2 if i do full dump from internal and import on production it would overwrite the online database, i mean i have online buyers on database web hosted and i want to migrate the internal database buys into live , can you please clarify BTW what will happen to auto increaments between two if they both were reserving same id it will be messy rigth !? – shareef May 6 '18 at 16:02
4

You can also use options like symmetricDS which can help in synchronizing two databases. With this you will be able to select the tables which needs to be synchronized that way you can save internet bandwidth. This would be also suit in the scenario when there is lack of connectivity between two locations.

2

How to set up database replication with MariaDB: https://www.techrepublic.com/article/how-to-set-up-database-replication-with-mariadb/

  • 1
    Welcome to DBA.SE. We appreciate your contribution/participation. However, the community does expect a certain quality in the answers posted. Please consider reading the following article: How do I write a good answer? (Help Centre) In the section Answer the question there is a short sentence which reads: Links to external resources are encouraged, but please add context around the link so your fellow users will have some idea what it is and why it’s there – John aka hot2use Sep 10 '18 at 6:26
0

You could use Navicat. It's primarily a db manager but it has data transfer and data synchronization functionality as well as a scheduler so you can automate. Its not free but there is a 30 full function trial.

protected by Community Sep 12 '18 at 19:02

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.