How do I turn off autocommit for a MySQL client?

后端 未结 7 666
灰色年华
灰色年华 2020-12-13 06:36

I have a web app that has been written with the assumption that autocommit is turned on on the database, so I don\'t want to make any changes there. However all the document

相关标签:
7条回答
  • 2020-12-13 07:14

    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

    0 讨论(0)
提交回复
热议问题