mysqldump Command Reference: Flags, Usage & CI Examples
mysqldump writes a MySQL or MariaDB database to a re-runnable SQL script.
mysqldump connects to a server and emits SQL (CREATE TABLE + INSERT) that recreates one or more databases. It is the standard logical backup tool for MySQL and MariaDB.
Common flags and usage
- --single-transaction: consistent InnoDB dump without table locks
- --databases <db...>: dump named databases with USE/CREATE
- --all-databases: dump every database
- --no-data / -d: schema only, no rows
- --routines / --triggers: include stored routines and triggers
- --add-drop-table: emit DROP TABLE before each CREATE
Example
shell
MYSQL_PWD=${MYSQL_PWD} mysqldump -h 127.0.0.1 -u root --single-transaction app > app.sqlIn CI
Add --single-transaction for InnoDB so the dump is consistent without taking a global read lock. Restore the result with the mysql client, not mysqldump. On MySQL 8 dumping needs the PROCESS privilege.
Key takeaways
- mysqldump produces a re-runnable SQL backup of MySQL/MariaDB.
- --single-transaction gives a consistent InnoDB snapshot, lock-free.
- Restore the output with the mysql client.
Related guides
mysql Command Reference: Flags, Usage & CI ExamplesReference for the mysql client: -h, -u, -p, -P, -e, MYSQL_PWD, forcing TCP, and a CI example that loads a sch…
mysqladmin Command Reference: Commands, Usage & CI ExamplesReference for mysqladmin: ping, status, create, --wait, --silent, and a CI wait loop that blocks until a MySQ…
pg_dump Command Reference: Flags, Usage & CI ExamplesReference for pg_dump: format flags (-F c/d/t/p), -f, -t, -n, --no-owner, and a CI example that exports a Pos…