I exported 2 identical databases(identical in terms of names and structures of tables) into two .sql files using mysqldump. I want to merge them into one file. However, both the
If you do not want to make dump once again and you are using Linux you can go with:
awk '!/^DROP TABLE IF EXISTS/{print}' <dump.file> | mysql <db_name>
If you want to dump data once again you should pass --skip-add-drop-table
to mysqldump utility.
I guess I don't see why a DROP TABLE statement should be problematic or why you need to merge dumps for two IDENTICAL databases.
That being said, you should probably just not add DROP TABLE in the initial dump. This would be controlled via flag use in your mysqldump command as noted in the documention at http://dev.mysql.com/doc/refman/5.5/en/mysqldump.html
This probably means you need to use --skip-opt
flag if you were using default options (default is to run as if --opt
flag is passed). You will then need to specify all flags within --opt
that you still want to use.
All you need is add --skip-add-drop-table
option when using mysqldump
.
$ mysqldump --databases --skip-add-drop-table -u root db1 > /tmp/qqq.2
So, there would not DROP TABLE IF EXISTS
in sql
files.
see docs of mysql on --skip-add-drop-table