views:

5176

answers:

1

Is there a way to restrict certain tables from the mysqldump command?

For example, I'd use the following syntax to dump only table1 and table2:

mysqldump -u username -p database table1 table2 > database.sql

But is there a similar way to dump all the tables except table1 and table2? I haven't found anything in the mysqldump documentation, so is brute-force (specifying all the table names) the only way to go?

+12  A: 

You can use the --ignore-table option. So you could do

mysqldump -u username -p database --ignore-table=database.table1 --ignore-table=database.table2 > database.sql
Brian Fisher
Thank you! Worked perfectly... I don't know how I missed that.
Zac
is there any way to just skip the table contents? the structure i want to backup.
andufo
You can use the --no-data=true option, but I don't know if you can do that on a per table level.
Brian Fisher