Backup MySQL database without locking tables
mysqldump -u testuser -p testdb --single-transaction > /tmp/backup_without_lock.sql
If you want to backup a MySQL database in a way that tables are not locked during the dump process - for example, if you want to backup a live database - use the --single-transaction
option of the mysqldump
utility.
The --single-transaction
option sets the transaction isolation mode to REPEATABLE READ
and sends a START TRANSACTION
SQL statement to the server before dumping data. It is useful only with transactional tables such as InnoDB, because then it dumps the consistent state of the database at the time when START TRANSACTION
was issued without blocking any applications.
When using this option, you should keep in mind that only InnoDB tables are dumped in a consistent state. For example, any MyISAM or MEMORY tables dumped while using this option may still change state.
- Import an SQL file using the command line in MySQL
- Backup only certain rows from MySQL database
- Create INSERT statement for each record with mysqldump
- Backup MySQL database without locking tables
- Backup MySQL data only
- Skip tables in MySQL backup
- Backup only selected tables in MySQL
- Backup MySQL schema only
- Backup MySQL database