mysql dump - exclude some table data

后端 未结 8 1353
独厮守ぢ
独厮守ぢ 2021-01-30 10:40

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

8条回答
  •  感情败类
    2021-01-30 10:52

    Another possibility that I use is to avoid the lines inserting data into the wanted table.

    The principle is to filter out the INSERT INTO lines using grep -v

    mysqldump name_of_db | grep -v 'INSERT INTO \`name_of_table\` VALUES'
    

    or

    mysqldump name_of_db | grep -v 'INSERT INTO \`name_of_db\`.\`name_of_table\` VALUES'
    

    That you can easily get into a gziped file and a separated error file

    mysqldump name_of_db | grep -v 'INSERT INTO \`name_of_db\`.\`name_of_table\`' | gzip > /path/dumpfile.sql.gz 2> /path/name_of_db.err
    

    and therefore get a nice backup of what you want and know what failed if any :-)

提交回复
热议问题