Create a compressed transaction-consistent MySQL database backup
Build a paste-ready command, then review its compatibility and effects before running it.
mysqldump --single-transaction --quick --routines --triggers --events --hex-blob -u root -p <database> | gzip -1 > <compressed-backup-file>Complete required fields to copy the generated command.
cautionwriterequires privileges Compatibility
InnoDB consistency--single-transaction provides a consistent snapshot for transactional tables without a global read lock; non-transactional tables require separate planning.
Operational knowledgereview due 2027-01-19
RequirementsBackup destinationConfirm that the destination has enough capacity and is not on the same failure domain as the database.Dump accountThe dump account needs access to the selected database and objects included by routines, triggers, and events.
Version supportmysqldump 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 errorsmysqldump: command not foundmysqldump is missing or is not available on PATH.Permission deniedThe current identity does not have the required access.
Verifygzip -t {{backupFile}} && gzip -dc {{backupFile}} | head -40gzip exits successfully and the preview contains a MySQL dump header plus expected CREATE or INSERT statements.RollbackDelete the newly created backup file if it is incomplete or stored in the wrong location; the database itself was not changed.
Command breakdown
01mysqldumpCommandRuns the mysqldump stage of this one-liner.
02--single-transactionOptionConfigures mysqldump with the --single-transaction option.
03--quickOptionConfigures mysqldump with the --quick option.
04--routinesOptionConfigures mysqldump with the --routines option.
05--triggersOptionConfigures mysqldump with the --triggers option.
06--eventsOptionConfigures mysqldump with the --events option.
07--hex-blobOptionConfigures mysqldump with the --hex-blob option.
08-uOptionConfigures mysqldump with the -u option.
09<administrative-mysql-user>ParameterA value supplied in the Fill parameters section.
10-pOptionSelects the command-specific port, process, or print mode.
11<database>ParameterA value supplied in the Fill parameters section.
12|PipelinePasses the output on the left to the command on the right.
13gzipCommandRuns the gzip stage of this one-liner.
14-1OptionConfigures gzip with the -1 option.
15>RedirectionRedirects command input, standard output, or error output.
16<compressed-backup-file>ParameterA value supplied in the Fill parameters section.
Example input
mysqldump --single-transaction --quick --routines --triggers --events --hex-blob -u root -p appdb | gzip -1 > appdb-2026-07-24.sql.gz
Example output
Enter password:
$ ls -lh appdb-2026-07-24.sql.gz
-rw-r----- 1 admin admin 18M Jul 24 10:42 appdb-2026-07-24.sql.gz
Illustrative output — exact values vary by system and data.
Official sources
Related commands