简体   繁体   English

MySQL通过mysqldump恢复数据库 - 它是否覆盖不同的目标表?

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

I am using mysqldump to backup a database containing several tables (say tables D, E, F). 我使用mysqldump来备份包含几个表的数据库(比如表D,E,F)。 I use the following command: mysqldump -uuser -ppassword SourceDatabase > file.sql to backup these tables. 我使用以下命令:mysqldump -uuser -ppassword SourceDatabase> file.sql来备份这些表。

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)? 例如,如果我有一个包含表A,B和C的数据库DestinationDatabase,并且在运行命令“mysql -uuser -ppassword DestinationDatabase <file.sql”之后,我将丢失目标数据库上的表A,B和C. (并留下D,E和F)或者我会留下A,B,C,D,E和F(DestinationDatabase中的原始表格保持不变)?

Thanks in advance, Tim 蒂姆,提前谢谢

With the default options, it will not delete tables A , B and C . 使用默认选项,它不会删除表ABC It will however overwrite (delete current data that is not in the backup) tables D , E and F . 然而,它将覆盖(删除不在备份中的当前数据)表DEF

To see the list of available options see here . 要查看可用选项列表,请参阅此处

它取决于执行备份时选项add-drop-tableadd-drop-database的值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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