How do I turn off autocommit for a MySQL client?

后端 未结 7 706
灰色年华
灰色年华 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 06:55

    Do you mean the mysql text console? Then:

    START TRANSACTION;
      ...
      your queries.
      ...
    COMMIT;
    

    Is what I recommend.

    However if you want to avoid typing this each time you need to run this sort of query, add the following to the [mysqld] section of your my.cnf file.

    init_connect='set autocommit=0'
    

    This would set autocommit to be off for every client though.

提交回复
热议问题