How to Backup Selected Tables by mysqldump

  • by
There're two ways to backup selected tables in MySQL:
  1. Positive Listing
  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. Negative Listing
  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 *