Skip to content

Instantly share code, notes, and snippets.

@takenoco82
Created November 17, 2018 07:44
Show Gist options
  • Save takenoco82/8ee42bcc0a5a5d6e9def49194537d681 to your computer and use it in GitHub Desktop.
Save takenoco82/8ee42bcc0a5a5d6e9def49194537d681 to your computer and use it in GitHub Desktop.
MySQLのオートコミット

MySQLのオートコミット

設定を確認・変更する

-- 設定を確認する
mysql> SELECT @@autocommit;
+--------------+
| @@autocommit |
+--------------+
|            1 | -- 1: オートコミット
+--------------+
1 row in set (0.00 sec)

-- オートコミットしない設定に変更する
mysql> SET AUTOCOMMIT=0;
Query OK, 0 rows affected (0.00 sec)

-- 変更内容を確認
mysql> SELECT @@autocommit;
+--------------+
| @@autocommit |
+--------------+
|            0 |
+--------------+
1 row in set (0.00 sec)

設定ファイルによる設定

# ここでは autocommit.cnf だけどファイル名は何でもOK
vi /etc/mysql/conf.d/autocommit.cnf
# /etc/mysql/conf.d/autocommit.cnf
[mysqld]
# 5.5.8〜なら以下の方法で設定できる
#   0: オートコミットoff, 1: オートコミット on
autocommit = 0

参考

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment