Skip to content
Home » MySQL » How to Backup Selected Tables

How to Backup Selected Tables

There're two ways to backup selected tables in MySQL:

  1. Include Table
  2. You can backup tables by positively and explicitly listing all necessary ones. The syntax is as following:

    mysqldump -h <host> -u <username> -p <db_name> <table_name> ...

    You may skip the host option -h if you operate in the localhost. For example:

    [root@localhost ~] mysqldump -u root -p db1 table1 table2 table3 > positive.sql
  3. Ignore Table
  4. You can backup tables by negatively and explicitly listing all non-necessary ones. The syntax is as following:

    mysqldump -h <host> -u <username> -p <db_name> --ignore-table=<db_name>.<table_name> ...

    You may skip the host option -h if you operate in the localhost. For example:

    [root@localhost ~] mysqldump -u root -p db1 --ignore-table=db1.table98 --ignore-table=db1.table99 > negative.sql

Leave a Reply

Your email address will not be published. Required fields are marked *