Add --single-transaction
and --quick
to your mysqldump
command.
--single-transaction
sets the isolation mode to REPEATABLE READ and starts a transaction before dumping data. useful for InnoDB tables, dumps the consistent state without blocking any applications.
--quick
retrieves ta row at a time from the server instead of the entire table, buffering it and writing it out.
From the mysldump doc:
To dump large tables, combine the --single-transaction option with the --quick option.
Before
mysqldump -h'hostname' -u'username' -p'password' 'livedbname'
- Dump time: ~6 Min.
- Website blocked
After
mysqldump -h'hostname' -u'username' -p'password' --single-transaction --quick 'livedbname'
- Dump time: 3 Min.
- Website not blocked!