Instead of switching autocommit off manually at restore time you can already dump your MySQL data in a way that includes all necessary statements right into your SQL file.
The command line parameter for mysqldump is --no-autocommit
. You might also consider to add --opt
which sets a combination of other parameters to speed up restore operations.
Here is an example for a complete mysqldump command line as I use it, containing --no-autocommit
and --opt
:
mysqldump -hlocalhost -uMyUser -p'MyPassword' --no-autocommit --opt --default-character-set=utf8 --quote-names MyDbName > dump.sql
For details of these parameters see the reference of mysqldump