MySQL restoring a database via mysqldump - Does it overwrite the different destination tables?

TMM picture TMM · Mar 29, 2011 · Viewed 9.4k times · Source

I am using mysqldump to backup a database containing several tables (say tables D, E, F). I use the following command: mysqldump -uuser -ppassword SourceDatabase > file.sql to backup these tables.

I would like to know if I restored this backup, would it overwrite other tables? For example, if I have a database DestinationDatabase, containing tables A, B and C, and after running the command "mysql -uuser -ppassword DestinationDatabase < file.sql", would I lose the tables A, B and C on the destination database (and be left with just D, E and F) or would I be left with A, B, C, D, E and F (with the original tables present in DestinationDatabase left untouched)?

Thanks in advance, Tim

Answer

The Scrum Meister picture The Scrum Meister · Mar 29, 2011

With the default options, it will not delete tables A, B and C. It will however overwrite (delete current data that is not in the backup) tables D, E and F.

To see the list of available options see here.