Reputation: 8893
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?
Upvotes: 19
Views: 26832
Reputation: 87
for dumping only the table data as stated in Dump only the data with mysqldump without any table information? do the following:
mysqldump --no-create-info ...
Also you may use:
--skip-triggers
: if you are using triggers
--no-create-db
: if you are using --databases ...
option
--compact:
if you want to get rid of extra comments
Upvotes: 1
Reputation: 1460
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
.
Upvotes: 28
Reputation: 978
Include the command for the mysqldump ignore the structure.
mysqldump --no-create-info ...
Upvotes: 31