I am currently trying to figure out the replication feature for Databases. I am new to this ,as until now I only used databases for simple inserts and selects for webpages.

Now I am trying to build a tool which can be used with no Internet Connection, when the person is outside in the field for work.

My thinking is to have a main DB on my server, which synchronies with a DB on a local webserver on a laptop before the person leaves to get some work done. When the person is outside in the field doing work, he will add new rows to the local DB. This rows needs to be synchronized with the master afterwards when the persons come back.

Like a Master - Slave sync for being on the current state of the DB and afterwards a Slave - Master sync so that the main DB is up to date and can give another person the current sync when needed.

Is this kind of possible or am I looking in the dark for such a solution?

  • I don't think MySQL/MariaDB replication is the best tool for this purpose. You might find a way to write your application to use MySQL/MariaDB directly, you might be able to find a synchronization tool (instead of a one way replication), or you might have success with a different database. As Rick James points out, Replication is meant to go only one direction (from the primary to the replica) and regardless, writing to two databases at the same time then trying to merge them will cause conflicts with auto increment keys. Merging well is one of the great challenges of an offline application.
    – ibennetch
    Commented Jul 22, 2023 at 3:12

1 Answer 1


In Primary-Replica replication (aka Master-Slave), writes should not occur on the Replica (except for those sent from the Primary).

It is possible to have Primary-Primary -- each is replicating from the other. But I don't think that is necessarily what you want. If you consider this topology, we need to discuss Unique keys and Auto_increments.

Will you be writing to the office server? Are there other laptops in the field?

Tentatively, I recommend that you flip the topology -- Your laptop is the Primary and the office server is a Replica (the only Replica). If there are multiple laptops in the field, read about "multi-Primary" replication.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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