mysqldump: exclude or skip specific tables with --ignore-table
Codemia Knowledge Hub ·
Use --ignore-table=database_name.table_name, and repeat the option once for every table you want to leave out. The database prefix is required on each one. People typically skip tables because of size, privacy, or because the tables are irrelevant to the snapshot.
Basic mysqldump usage
mysqldump exports a database as a logical backup (SQL) that you can import again with mysql or another tool that reads SQL files:
This connects to the MySQL server as the given user and writes the chosen database to the output file. Everything below just adds options to this command.
Excluding one table
To skip table_to_skip in my_database:
Excluding several tables
There is no comma-separated form. Repeat --ignore-table for each table you want to skip:
A concrete case: business_db has orders, customers, archived_orders and logs, and you want a backup without logs and archived_orders:
Option reference
| Option | Description |
--ignore-table=db.tbl | Excludes the specified table from the dump. Specify full <database>.<table>. |
-u [username] | Connects to the MySQL server as the specified user. |
-p | Prompts for the password. Use it without password for security reasons. |
[database_name] | Specifies the database to be dumped. |
Things to check when excluding tables
- Dependencies: skipping tables shrinks the dump and speeds it up, but dependencies between tables (such as foreign keys) are not handled for you.
- Quoting: quote or escape table names that contain special characters or spaces, or the shell will mangle them.
- Full backups: if your backup strategy needs complete snapshots, keep a separate routine that includes every table, especially for critical databases.
- Other options:
--ignore-tablecombines with options such as--single-transactionfor consistent dumps and--quickto avoid loading large tables into memory. - Scripting: if you exclude tables regularly, generate the
--ignore-tablearguments in a shell script. - Restore tests: test that the dump restores and that the missing tables do not break your data integrity checks.
Related reading
- How to solve the “failed to lazily initialize a collection of role” Hibernate exception
- How to sort a collection by date in MongoDB?
- How to sort mongodb with pymongo
- How to specify an Order or Sort using the C driver for MongoDB?
- How to specify packagesToScan in HibernateJpaAutoConfiguration?
- How to split the name string in mysql?
- How to start MySQL server from command line on Mac OS Lion?
- How to start spring-boot app without depending on Database?
System design interview problems on this topic
- Design a Distributed OLTP Database: solution and walkthrough
- Design a Wide Column Database: solution and walkthrough
- Design a Key Value Store: solution and walkthrough
- Design a Web Cache: solution and walkthrough

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseSystem Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.