Hands-on Lab·MySQL
MySQL Logical Backups with mysqldump
A dump is a text file of SQL statements that rebuilds the database. --single-transaction is the flag that makes it consistent without locking anyone out, and it is the one most people leave off.
Backup and Restore Guide 21 of 45 Beginner
- OSUbuntu 26.04 LTS
- MySQL8.4.10-0ubuntu0.26.04.1
- BinlogROW format, enabled by default
- TimeAbout 13 min
--single-transaction gives a consistent snapshot for InnoDB tables only. A schema mixing InnoDB and MyISAM cannot be dumped consistently without locking.
| Server Name | IP Address | OS | Roles | CPU | RAM | HDD |
|---|---|---|---|---|---|---|
| db-a01 | 192.168.0.81 | Ubuntu 26.04 LTS | Primary / Source / Replica Set Member 1 | 2 Core | 4 GB | 50 GB |
This guide includes
Use this when you need a backup you can actually read. This matters because a dump is plain SQL that rebuilds the database - and a backup nobody has looked inside is a hypothesis rather than a backup.
- taking the dump, with four choices each worth understanding
- looking at what a dump actually is - plain, readable SQL
- confirming it contains both the structure and the data
Before you start
- The
appdbdatabase with the customers and orders tables.
-
Take the dump
-
Look at what a dump actually is
-
Confirm it contains both structure and data