16

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?

Kellen Stuart
  • 7,775
  • 7
  • 59
  • 82

3 Answers3

24

Include the command for the mysqldump ignore the structure.

mysqldump --no-create-info ...

20

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.

Maroun
  • 94,125
  • 30
  • 188
  • 241
mcv
  • 1,380
  • 3
  • 16
  • 41
1

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

Timo
  • 59
  • 7