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?

1 answer

  • answered 2018-10-11 19:40 LuRsT

    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.