T
T
Taras Labiak2018-05-15 03:51:08
MySQL
Taras Labiak, 2018-05-15 03:51:08

How to update one database by getting updates from another with MySQL?

There are two databases A and B. A person works with database A, constantly making changes. At some points, after executing a certain command, it is necessary that changes from base A be transferred to base B. Base B does not change on its own.
I guess the easiest way to do this is with replication . But I never set up replication and I don’t know if it’s possible to do synchronization only when it’s needed.
I also assumed that you can create triggers that update updated_at or add it to a special table in case of deletion. There is also the most difficult option, but it looks reliable - to hash each record and then compare these hashes, difficulties can arise if the primary key consists of several fields.
In the database, some tables have updated_at and some don't. One wordpress plugin uses its tables with updated_at. I don’t really like the migration option, since having my own script could clearly track changes and save them to git, for example. The MySQL version control feature itself would be very useful for troubleshooting.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Ruslan Fedoseev, 2018-05-15
@martin74ua

Replication.
In your case, it is configured in half an hour of reading examples from Google.

M
moropsk, 2018-05-16
@moropsk

Setting up replication in MySQL
https://ixnfo.com/nastroyka-replikatsii-v-mysql.html

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question