略微加速

略速 - 互联网笔记

MySQL设置数据库隔离级别

2020-09-15 leiting (2618阅读)

标签 MySql

可以通过命令行设置全局 或 会话的隔离级别。重启或者退出会话失效

SET [SESSION | GLOBAL] TRANSACTION ISOLATION LEVEL {READ UNCOMMITTED | READ COMMITTED | REPEATABLE READ | SERIALIZABLE}

 具体命令

# 设置全局隔离级别

set global transaction isolation level REPEATABLE READ;
set global transaction isolation level  READ COMMITTED;
set global transaction isolation level READ UNCOMMITTED;
set global transaction isolation level SERIALIZABLE;

#设置会话隔离级别 

set session transaction isolation level REPEATABLE READ;
set session transaction isolation level READ COMMITTED;
set session transaction isolation level READ UNCOMMITTED;
set session transaction isolation level SERIALIZABLE;

通过配置文件设置隔离级别 

[mysqld]
transaction-isolation = REPEATABLE-READ
transaction-isolation = READ-COMMITTED
transaction-isolation = READ-UNCOMMITTED
transaction-isolation = SERIALIZABLE

查看隔离级别

SELECT @@GLOBAL.transaction_isolation
SELECT @@SESSION.transaction_isolation
show variables like '%iso%';


https://dev.mysql.com/doc/refman/5.7/en/set-transaction.html


北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3