简体   繁体   中英

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. 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. Is there any flag I can pass mysqldump to achieve this?

Include the command for the mysqldump ignore the structure.

mysqldump --no-create-info ...

All you need is add --skip-add-drop-table option when using mysqldump .

$ 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.

see docs of mysql on --skip-add-drop-table .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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