首页 > 数据库 >mysql隔离级别参数和会话动态设置--笔记

mysql隔离级别参数和会话动态设置--笔记

时间:2022-11-23 17:59:23浏览次数:51  
标签:none set -- isolation 7308 笔记 mysql root localhost

1、参数设置
可选参数有:READ-UNCOMMITTED, READ-COMMITTED, REPEATABLE-READ, SERIALIZABLE.
如:
transaction_isolation = REPEATABLE-READ

transaction-isolation = READ-COMMITTED


2、动态设置方式
# 未提交读级别
set session transaction isolation level read uncommitted;
# 已提交读级别
全局
set global tx_isolation = 'READ-COMMITTED'
set global transaction isolation level read committed;
会话
set tx_isolation = 'READ-COMMITTED'
set session transaction isolation level read committed;
# 可重复读级别
全局
set global tx_isolation = 'REPEATABLE-READ'
set global transaction isolation level repeatable read;
会话
set tx_isolation = 'REPEATABLE-READ'
set session transaction isolation level repeatable read;
# 可串行化级别
set session transaction isolation level serializable;

 

[mysql@localhost ~]$ mysql.7308.login 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1533
Server version: 5.6.47-87.0-log huanglingfei make install Percona Server

Copyright (c) 2009-2020 Percona LLC and/or its affiliates
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

root@localhost: 01:23 [7308][(none)]>help set;
Name: 'SET'
Description:
Syntax:
SET variable = expr [, variable = expr] ...

variable: {
    user_var_name
  | param_name
  | local_var_name
  | {GLOBAL | @@GLOBAL.} system_var_name
  | [SESSION | @@SESSION. | @@] system_var_name
}

SET ONE_SHOT system_var_name = expr

SET syntax for variable assignment enables you to assign values to
different types of variables that affect the operation of the server or
clients:

o User-defined variables. See
  https://dev.mysql.com/doc/refman/5.6/en/user-variables.html.

o Stored procedure and function parameters, and stored program local
  variables. See
  https://dev.mysql.com/doc/refman/5.6/en/stored-program-variables.html
  .

o System variables. See
  https://dev.mysql.com/doc/refman/5.6/en/server-system-variables.html.
  System variables also can be set at server startup, as described in
  https://dev.mysql.com/doc/refman/5.6/en/using-system-variables.html.

URL: https://dev.mysql.com/doc/refman/5.6/en/set-variable.html


root@localhost: 01:24 [7308][(none)]>

 

root@localhost: 01:24 [7308][(none)]>show variables like '%iso%';
+---------------+----------------+
| Variable_name | Value          |
+---------------+----------------+
| tx_isolation  | READ-COMMITTED |
+---------------+----------------+
1 row in set (0.00 sec)
oot@localhost: 01:29 [7308][(none)]>show global variables like '%iso%';
+---------------+----------------+
| Variable_name | Value          |
+---------------+----------------+
| tx_isolation  | READ-COMMITTED |
+---------------+----------------+
1 row in set (0.00 sec)

root@localhost: 01:30 [7308][(none)]>

root@localhost: 01:25 [7308][(none)]>
root@localhost: 01:26 [7308][(none)]>select @@tx_isolation;    
+----------------+
| @@tx_isolation |
+----------------+
| READ-COMMITTED |
+----------------+
1 row in set (0.00 sec)

root@localhost: 01:26 [7308][(none)]>select @tx_isolation; 
+---------------+
| @tx_isolation |
+---------------+
| NULL          |
+---------------+
1 row in set (0.00 sec)

root@localhost: 01:26 [7308][(none)]>

 

root@localhost: 02:37 [7308][(none)]>set global tx_isolation = 'REPEATABLE-READ';
Query OK, 0 rows affected (0.00 sec)

root@localhost: 02:57 [7308][(none)]>show global variables like '%iso%';
+---------------+-----------------+
| Variable_name | Value           |
+---------------+-----------------+
| tx_isolation  | REPEATABLE-READ |
+---------------+-----------------+
1 row in set (0.00 sec)

root@localhost: 02:57 [7308][(none)]>show variables like '%iso%';       
+---------------+----------------+
| Variable_name | Value          |
+---------------+----------------+
| tx_isolation  | READ-COMMITTED |
+---------------+----------------+
1 row in set (0.00 sec)

root@localhost: 02:57 [7308][(none)]>set tx_isolation = 'REPEATABLE-READ';
Query OK, 0 rows affected (0.00 sec)

root@localhost: 02:58 [7308][(none)]>show variables like '%iso%';
+---------------+-----------------+
| Variable_name | Value           |
+---------------+-----------------+
| tx_isolation  | REPEATABLE-READ |
+---------------+-----------------+
1 row in set (0.00 sec)

root@localhost: 02:58 [7308][(none)]>
root@localhost: 02:58 [7308][(none)]>set session transaction isolation level serializable;
Query OK, 0 rows affected (0.00 sec)

root@localhost: 02:58 [7308][(none)]>show variables like '%iso%';
+---------------+--------------+
| Variable_name | Value        |
+---------------+--------------+
| tx_isolation  | SERIALIZABLE |
+---------------+--------------+
1 row in set (0.00 sec)

root@localhost: 02:58 [7308][(none)]>show global variables like '%iso%';
+---------------+-----------------+
| Variable_name | Value           |
+---------------+-----------------+
| tx_isolation  | REPEATABLE-READ |
+---------------+-----------------+
1 row in set (0.00 sec)

root@localhost: 02:59 [7308][(none)]>set global transaction isolation level serializable;
Query OK, 0 rows affected (0.00 sec)

root@localhost: 02:59 [7308][(none)]>show global variables like '%iso%';
+---------------+--------------+
| Variable_name | Value        |
+---------------+--------------+
| tx_isolation  | SERIALIZABLE |
+---------------+--------------+
1 row in set (0.00 sec)

root@localhost: 02:59 [7308][(none)]>

标签:none,set,--,isolation,7308,笔记,mysql,root,localhost
From: https://www.cnblogs.com/hsjz-xinyuan/p/16919191.html

相关文章

  • 如何检索对象中是否包含某个属性
    常用的方法一共有三种,可以根据需求自行选择~ 1. hasOwnproperty()这个方法是最常用的,所有继承了Object的对象都会继承到hasOwnProperty方法。和in运算符不同,该......
  • 封校小记
    翻相册之时发现封校已然一月整,困于宿舍的无趣生活不免催生摆烂心态,各ddl重压下的情形下反而更加有记一记近日生活的欲望,本想压一压等周末把作业高差不多再写,不过“ddl只会......
  • 6. python和Redis交互
    1安装包pipinstallredis2引入模块fromredisimport*这个模块中提供了StrictRedis对象(Strict严格),用于连接redis服务器,并按照不同类型提供了不同方法,进行交互操作......
  • VulnHub靶场渗透实战8-DarkHole: 2
    靶场地址:DarkHole:2~VulnHubDescriptionBacktotheTopDifficulty:HardThisworksbetterwithVMwareratherthanVirtualBoxHint:Don'twasteyourtimeForB......
  • Oracle函数NULLIF
    1、NULLIF函数函数语法:NULLIF(Expression1,Expression2)函数功能:如果来个表达式相等,则返回NULL值,否则返回第一个表达式功能很简单,但是要注意以下几种情况:1)两个......
  • 7. 主从配置
    一个master可以拥有多个slave,一个slave又可以拥有多个slave,如此下去,形成了强大的多级服务器集群架构master用来写数据,slave用来读数据,经统计:网站的读写比率是10:1通过主......
  • spring-security
    springSecurity设置用户名和密码一.配置文件中设置springl.security.user.name=xxxspring.security.user.password=xxx二.配置类中设置@Configurationpublicclass......
  • LT-OCF: Learnable-Time ODE-based Collaborative Filtering
    目录概符号说明本文方法代码ChoiJ.,JeonJ.andParkN.LT-OCF:Learnable-timeode-basedcollaborativefiltering.InInternationalConferenceonInformationa......
  • Java阻塞队列中的异类,SynchronousQueue底层实现原理剖析
    上篇文章谈到BlockingQueue的使用场景,并重点分析了ArrayBlockingQueue的实现原理,了解到ArrayBlockingQueue底层是基于数组实现的阻塞队列。但是BlockingQueue的实现类中,有......
  • 8. 集群配置
    1为什么要有集群一主可以多从,如果同时访问量过大(1000w),主服务肯定就会挂掉,数据服务挂掉了或者发生自然灾难大公司都会有很多服务器(华东地区、华南地区、华中地区、......