mysql copy database over an exisiting one

I face a common situation where I have a number of copies of a database that need to be synced to a master copy every so often. For example a live version, a demonstration version and a sandbox version. The easiest way seems to be the following:

mysqldump -uUsername -pPassword --add-drop-table db_name1 | mysql -uUsername -pPassword db_name2

This avoids having to delete and recreate the destination database. To copy it to another host add the "-h" option. If the destination database does not already exist run:

mysqladmin -uUsername -pPassword create db_name2

Unfortunately, there is still a lot of redundancy in this appoach as it wipes all the data and then replaces it even if there are only a few records different.

Comments

Popular posts from this blog

A census of amplified and overexpressed human cancer genes : Nature Reviews Cancer

Universal Scrobbler

RT @CancerInNorwich: 📢 Join us on Monday at 1pm for the next talk in our virtual seminar series. We will be hearing from Dr Wafa Al-Jamal from @QUBelfast, who will be talking about "Smart Nanomedicimes for Pancreatic Cancer". All are welcome to join via the MS Teams link: https://t.co/4xCYpjGuBZ https://t.co/EGyD4NAgeP