Restore a compressed SQL backup into a MySQL database
Build a paste-ready command, then review its compatibility and effects before running it.
gzip -dc <compressed-backup-file> | mysql --binary-mode=1 -u root -p <database>Complete required fields to copy the generated command.
dangerwritedestructiverequires privileges Destructive command. Review the target and use a preview or dry-run variant first. Safer first stepgzip -t {{backupFile}} && gzip -dc {{backupFile}} | head -80Validate the compressed stream and inspect the SQL header before executing any statement. Compatibility
Destructive importStatements in the dump can replace schemas and data. Restore into a new database first whenever possible.
Operational knowledgereview due 2027-01-19
RequirementsValidated SQL backupRun the supplied preview command and verify the dump source, target database, server version, character set, and available space.Current target recovery pointTake and validate a fresh backup of the current target before importing.
Version supportgzip Current supported releasesVerified for linux using posix, bash, zsh syntax; consult compatibility notes for platform-specific differences.
Expected signalsEnter password:Representative successful output; values vary with the selected target and system state.
Known errorsgzip: command not foundgzip is missing or is not available on PATH.Permission deniedThe current identity does not have the required access.
Verifymysql -u {{adminUser}} -p -e "USE {{database}}; SHOW TABLES;"The expected schema objects are present and application-specific row-count or integrity checks pass.RollbackRestore the pre-import backup into a clean database and switch the application back after validation.
Command breakdown
01gzipCommandRuns the gzip stage of this one-liner.
02-dcOptionConfigures gzip with the -dc option.
03<compressed-backup-file>ParameterA value supplied in the Fill parameters section.
04|PipelinePasses the output on the left to the command on the right.
05mysqlCommandRuns the mysql stage of this one-liner.
06--binary-mode=1OptionConfigures mysql with the --binary-mode=1 option.
07-uOptionConfigures mysql with the -u option.
08<administrative-mysql-user>ParameterA value supplied in the Fill parameters section.
09-pOptionSelects the command-specific port, process, or print mode.
10<database>ParameterA value supplied in the Fill parameters section.
Example input
gzip -dc appdb-2026-07-24.sql.gz | mysql --binary-mode=1 -u root -p appdb
Example output
Enter password:
$ mysql -u root -p -Nse "SELECT COUNT(*) FROM appdb.users;"
Enter password:
18427
Illustrative output — exact values vary by system and data.
Official sources
Related commands