简体   繁体   中英

How to update mySQL table starting from a dump?

I'm working with a mySQL database located on a separate cluster. Since the changes were few, I was just dumping the whole db and porting it to a fresh database each time. But now changes on the main db are more frequent, so I am looking for something that allows me to just "update" the tables of my existing db after having dumped it from the main site.

I am dumping the db using

mysqldump --master-data -h my_main_server -u my_dump_user -pmy_password mydb > dbdump.sql

How can I use it to "update" my current db?

Since you'd have the tables created already, the dump would fail whilst trying to create them, so for you to be able to execute the dump, you need to drop all the existing tables in the database.

You could have instructions in your dump to do that, so you could execute that command without a problem, or you can just reset the database.

If you really need to update some parts of the db with that dump, you could just comment out all the ALTER and CREATE TABLE instructions and just keep the INSERTS, if that's what you want.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM