9

I have a big database with 100 tables I'm need to create dump. 98 tables with data and 2 tables only structure

like this

mysqldump -u root -p {--no-data db.table99,  table10 } dbname > dump.sql

how can i do it with one request ?

Serhii Danovskyi
  • 385
  • 3
  • 17
  • use the --ignore-table, as it is described here https://stackoverflow.com/questions/425158/skip-certain-tables-with-mysqldump – fxlacroix Sep 12 '17 at 13:31
  • 1
    Possible duplicate of [Skip certain tables with mysqldump](https://stackoverflow.com/questions/425158/skip-certain-tables-with-mysqldump) – fxlacroix Sep 12 '17 at 13:31

1 Answers1

13

mysqldump either includes the data, or doesn't. You can't do it with one query.

However, you can safely combine two mylsqdumps request into ONE file on bash. First one excludes the tables you don't want but has data, second one has only the 2 tables with no data:

{ command1 & command2; } > new_file

command1 => mysqldump -u root -p --ignore-table=dbname.table99 --ignore-table=dbname.table100 dbname

command2 => mysqldump --no-data -u root -p dbname table99 table100

Unfortunately, you'd have to supply the password twice. But since you want one line, you can put this in a bash script

Jacques Amar
  • 1,803
  • 1
  • 10
  • 12