mysqldump entire structure but only data from selected tables in a single command

前端 未结 5 621
感情败类
感情败类 2021-01-30 05:39

My database has 3 tables: table1, table2 and table3

I would like to do a mysqldump on this database with the following conditions:

  • Dump structure for all t
5条回答
  •  逝去的感伤
    2021-01-30 05:55

    I don't think you can do it in one command. But you definitely can merge the output to one file. Why not to wrap it in some shell script that does following:

    mysqldump -u $1 -p$2 -d db > dump.sql && mysqldump -u $1 -p$2 db --ignore-table=db.table3 >> dump.sql
    

    You will run this script with two parameters: username and password.

提交回复
热议问题