[英]How to mysqldump WITHOUT dropping any tables
Normally, when I backup the database, I run a command like this:通常,当我备份数据库时,我会运行如下命令:
mysqldump -uuser -p -hhost -Ddatabase > C:\TEMP\db_2018-04-05.sql
Inside that file, there are DROP table
statements.在该文件中,有DROP table
语句。 This is normally fine, but I've modified my localhost to have a different schema than the production database.这通常很好,但我已经修改了我的本地主机,使其具有与生产数据库不同的架构。
If I execute this file, it will blow away the important changes to the database schema on my localhost.如果我执行此文件,它将消除对本地主机上数据库架构的重要更改。
All I need is the INSERT
statements.我只需要INSERT
语句。 Is there any flag I can pass mysqldump
to achieve this?是否有任何标志我可以通过mysqldump
来实现这一目标?
Include the command for the mysqldump ignore the structure.包括命令为 mysqldump 忽略结构。
mysqldump --no-create-info ... mysqldump --no-create-info ...
All you need is add --skip-add-drop-table
option when using mysqldump
.您只需要在使用mysqldump
时添加--skip-add-drop-table
选项。
$ mysqldump -uuser -p -hhost -Ddatabase --skip-add-drop-table > C:\TEMP\db_2018-04-05.sql
Now no DROP TABLE IF EXISTS in SQL files.现在 SQL 文件中没有 DROP TABLE IF EXISTS。
see docs of mysql on --skip-add-drop-table
.请参阅--skip-add-drop-table
上的mysql文档。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.