IT study

[MySQL] AutoCommit 설정 값 조회 및 변경 본문

DATABASE/Mysql MariaDB

[MySQL] AutoCommit 설정 값 조회 및 변경

DBnA 2025. 3. 14. 17:13

1. AutoCommit 설정값 조회

  1) select @@autocommit; --1:true, 0:false

  2) show variables like 'autocommit';

 

2. AutoCommit 설정값 변경

 1) 세션단위 변경 : set autocommit = false / true;

 2) DB레벨 변경 :

 /etc/my.cnf.d/server.cnf > autocommit 값 변경 - 0:autocommit 해제 , 1 : autocommit 설정

 

mysql> select @@autocommit;
+--------------+
| @@autocommit |
+--------------+
|            1 |
+--------------+
1 row in set (0.00 sec)

mysql> show variables like 'autocommit';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| autocommit    | ON    |
+---------------+-------+
1 row in set (0.00 sec)

mysql> set autocommit = false;
Query OK, 0 rows affected (0.00 sec)

mysql> show variables like 'autocommit';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| autocommit    | OFF   |
+---------------+-------+
1 row in set (0.00 sec)