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

 

posted @ 2020-05-08 21:21  DBA社区  阅读(6505)  评论(0编辑  收藏  举报