Is it possible, using mysql dump to export the entire database structure, but exclude certain tables data from export.
Say the database has 200 tables, I wish to export
I am a new user, and do not have enough reputation to vote or comment on answers, so I am simply sharing this as an answer.
@kantholy clearly has the best answer.
@AmitP's method dumps all structure and data
to a file
, and then a drop/create table
statement at the end. The resulting file will still require you to import
all of your unwanted data before simply destroying it.
@kantholy's method dumps all structure first, and then only data
for the table
you do not ignore. This means your subsequent import
will not have to take the time to import
all the data
you do not want - especially important if you have very large amounts of data
you want to ignore to save time.
To recap, the most efficient answer is:
mysqldump --no-data db_name > export.sql
mysqldump --no-create-info --ignore-table=db_name.table_name1 [--ignore-table=db_name.table_name2, ...] db_name >> export.sql