How to sync and merge local MySQL db with server MySQL db? - mysql

I have an app with a MySQL db running on a local network and I need to host it online. I need to work on the local version of the app on the local network and the server version outside the network.
I need the data to be consistent where the db is the same locally and on the server. Assume the same fields will not change on both (no merge conflict) and that sync and merge can take place once everyday - at the end of the day. Data may change on the local version, server version or both, that's why I need a merge. I've seen many other posts but couldn't find a clear solution.
How is that possible?

Related

2 way sync of MySQL databases

A web application runs both on live and local server with live and local database server. Users use live server to add the data, whereas internal staffs use the local application to update the data. After some time, both of these databases have to be synchronized properly without loss of data from live or local database server. I don't want an exact replica of live database in local database or vice-versa but databases need to synchronize values which have been entered in it.

How to merge local and remote databases?

I am working with a live site that is dependent on a database (which I have access to). I have copied the site locally and am running it with MAMP. All of the files from the server are version-controlled using git, so the files on my localhost are always up to date with the ones on the server.
However, the database doesn't work as well as the files. To merge the changes from the live database I have to export it as a .sql file, then import it into my localhost. However, if the local database changes, those aren't reflected when I re-import. How can I merge the changes so that I keep my local database updates, but "pull" the remote changes so it is up to date?
Well, you have multiple options here.
You can use FEDERATED Storage Engine and can query the remote database locally. FEDERATED Storage Engine is kind of same as Linked Server in MS SQL Server
You can as well set up Replication between the servers (Transactional Replication). In which case, depending on the setup data from primary will get synced with the secondary server; if not instantly but over a period of time.
You can as well User MySQL BackUp and Restore procedure. I mean specifically, Differential/Incremental Backup

how to synchronize two databases of different servers?

I have two databases. One is on local server and the other is on a production server. I'm continuously working on the local server and after approval I want to update production server. Wih the current setup, I need to take dump or copy or export of database and then import into production database, every time. Is there any way of synchronization method in phpmyadmin for database on different server.
It is possible to synchronize a model in MySQL Workbench with a live database?
Other then this, how can I do this? I'm able to use queries, the command line and phpmyadmin itself.
Please specified any simple method.
The "synchronisation" feature you are looking for is called replication. A replication can be set up between a master and a slave machine. It does not rely on a constant connection, but stores all changes on the master and replays all those changes on the slave once a connection is established.

How to copy new and updated rows from a offline to an online database?

It's one of those cases where you have a desktop application and its database is in a remote server. In my case, it's MySQL and the application is made in Delphi XE3. But when client wants his data both offline and online (for speed and security) we need to:
Login with remote server information (more updated);
Sync the online database to offline;
Do the tasks on the application and the database;
Sync back the offline database with online.
My question: Is there a standard way to do that, by MySQL instructions or another automatic way? Or Am I going to code all the rules to make it possible?
Luckily there is no need for code here.
Replication has been built into MySQL for many years.
The trick is to setup the remote host as master and the local copy as slave.
All updates go to the master.
And the slave reads from the remote.
The documentation is here: http://dev.mysql.com/doc/refman/5.7/en/replication.html
Here's a tutorial: http://www.howtoforge.com/mysql_master_master_replication
Note that there can really only be one master, if not the setup will get too complicated to be workable.
You could look at client data sets (as you need to update the local version I do not believe that mysql allows multiple masters). Basically your application connects to mysql when it is online and if your application goes offline you store the database and changes in a local xml database. One back online, you apply the updates. Downsides of cds are.: no sql locally and your local changes might conflict with changes made by other users so the apply updates must include logic to reconcile the conflicts. Also cds is involved still trying to get my head around it

Sync Local Microsoft MySQL database to remote mysql database scheduled daily

Hi i have a local mysql database that gets updated locally daily on windows machine. at the end of the day, i want a scheduled job to be called by windows that updates a remote mysql database with all the the new data ie compare and synchronize.
i have already created the test database on remote server and ive allowed remote access. i want simple program/solution that i could call on command line that updates remote database with new or changed records etc.
the local database is on a windows machine and remote database is on a webserver with debian.
MySQL allows replication: you wouldnt need to use a specific app, have you looked at http://dev.mysql.com/doc/refman/5.0/en/replication-howto.html