How to Make a mysqldump File Smaller
Before you fight import limits, shrink the dump. Compression, dropping logs, schema-only exports, and the flags that cut file size the most.
Sometimes the best fix for an oversized dump is to make it not oversized. A few export choices can cut a dump by 70–90% before it ever touches an import limit.
1. Compress it (the biggest single win)
mysqldump database_name | gzip > dump.sql.gzSQL is extremely compressible — text, repeated keywords, repeated structure. gzip routinely shrinks a dump to 10–20% of its original size. Most import tools (CLI, Cloud SQL, even SQLSplit) read .gz directly.
2. Skip the data you don't need
Cache, session, and log tables are often the bulk of a database and rarely worth migrating. Exclude their data while keeping their structure:
mysqldump database_name \
--ignore-table=database_name.wp_actionscheduler_logs \
--ignore-table=database_name.sessions \
> dump.sql
# Or dump structure-only for heavy tables, data for the rest:
mysqldump --no-data database_name big_log_table > schema_only.sql3. Use extended inserts (smaller and faster)
Extended inserts pack many rows per statement, which shrinks the file and speeds up import. It's on by default, but make sure it isn't disabled:
mysqldump --extended-insert --quick database_name > dump.sql4. Drop binary log / GTID noise
mysqldump --skip-comments --set-gtid-purged=OFF \
--no-tablespaces database_name > dump.sql- --skip-comments removes the verbose header/footer comments
- --set-gtid-purged=OFF avoids GTID statements that also cause import privilege errors
- --no-tablespaces avoids PROCESS-privilege warnings on managed hosts
5. Separate schema from data
Two smaller files are easier to handle than one big one — and you can import schema once, then load data in pieces:
mysqldump --no-data db > schema.sql
mysqldump --no-create-info db > data.sqlStill too big after shrinking?
Split the remaining dump into importable chunks — works on .sql and .sql.gz alike.
Open SQLSplitFrequently Asked Questions
How do I reduce the size of a mysqldump file?
Compress it with gzip (often a 5–10x reduction), exclude bulky log/cache/session table data with --ignore-table, ensure --extended-insert is on, and strip comments and GTID statements. Separating schema from data also makes the pieces easier to handle.
Can I import a gzipped SQL dump without decompressing it?
Yes. The MySQL CLI can read it via a pipe (gunzip < dump.sql.gz | mysql ...), Cloud SQL imports .gz natively, and tools like SQLSplit accept .gz directly. Keeping it compressed saves a lot of disk and transfer time.
Which mysqldump options make the dump smallest?
--extended-insert (packs rows), piping through gzip (biggest win), --ignore-table for log/cache tables, --skip-comments, and --no-data for tables you only need the structure of.