<pre name="code" class="html">Session 1:
mysql> use zjzc;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A Database changed
mysql> select * from test;
+------+------+
| id | name |
+------+------+
| NULL | a |
| 2 | b |
| 3 | c |
| 1 | a |
+------+------+
4 rows in set (0.00 sec) mysql> lock table test read;
Query OK, 0 rows affected (0.00 sec) mysql> select * from test;
+------+------+
| id | name |
+------+------+
| NULL | a |
| 2 | b |
| 3 | c |
| 1 | a |
+------+------+
4 rows in set (0.00 sec) mysql> insert into test values(4,'a');
ERROR 1099 (HY000): Table 'test' was locked with a READ lock and can't be updated Session 2: Database changed
mysql> select * from test;
+------+------+
| id | name |
+------+------+
| NULL | a |
| 2 | b |
| 3 | c |
| 1 | a |
+------+------+
4 rows in set (0.00 sec) mysql> insert into test values(4,'a'); 由于session 1加了只读锁,session2无法插入 session 2也可以加只读锁;
mysql> lock table test read;
Query OK, 0 rows affected (0.00 sec) mysql> insert into test values(4,'a');
ERROR 1099 (HY000): Table 'test' was locked with a READ lock and can't be updated 一个session只能为自己获取锁和释放锁,不能为其他session获取锁,也不能释放由其他session保持的锁。 UNLOCK TABLES还还以用来释放FLUSH TABLES WITH READ LOCKS获取的全局锁,该锁锁定所有库的所有表。 /*************
[root@wx03 sbin]# perl a2.pl
$XDATE is 20160823132742
DBD::mysql::db do failed: Table 't1' was locked with a READ lock and can't be updated at a2.pl line 12.
[root@wx03 sbin]# cat a2.pl
use DBI;
use POSIX;
$db_name='scan';
$ip='127.0.0.1';
$user="root";
$passwd="R00t,uHagt.0511";
$dbh = DBI->connect("dbi:mysql:database=$db_name;host=$ip;port=3306",$user,$passwd
) or die "can't connect to database ". DBI-errstr;
my $XDATE = strftime("%Y%m%d%H%M%S",localtime());
print "\$XDATE is $XDATE\n";
$dbh->do("lock table t1 read") or die $dbh->errstr ;
$dbh->do("insert into t1 values(90)");
$dbh->disconnect; [root@wx03 sbin]# perl a2.pl
$XDATE is 20160823132747
DBD::mysql::db do failed: Table 't1' was locked with a READ lock and can't be updated at a2.pl line 12.
												

mysl lock table read的更多相关文章

  1. MYSQL 遭遇 THE TOTAL NUMBER OF LOCKS EXCEEDS THE LOCK TABLE SIZE

    今天进行MySql 一个表数据的清理,经过漫长等待后出现 The total number of locks exceeds the lock table size 提示.以为是table_cache ...

  2. mysql:The total number of locks exceeds the lock table size

    使用mysql InnoDB存储引擎进行大量数据的更新,删除的时候容易引发”The total number of locks exceeds the lock table size”问题,解决方法之 ...

  3. MySQL配置文件路径及‘The total number of locks exceeds the lock table size’问题

    在删除mysql中的数据时,遇到报错: ERROR 1206 (HY000): The total number of locks exceeds the lock table size 查了查,发现 ...

  4. mysql报错"ERROR 1206 (HY000): The total number of locks exceeds the lock table size"的解决方法

    1. 问题背景         InnoDB是新版MySQL(v5.5及以后)默认的存储引擎,之前版本的默认引擎为MyISAM,因此,低于5.5版本的mysql配置文件.my.cnf中,关于InnoD ...

  5. lock table

    1.在执行lock table语句后,则在执行unlock tables之前,当前会话只能操作当前被锁定的表(包括表别名)2.read锁,其它会话只有读取权限,没有写入权限3.write锁,其它会话只 ...

  6. Mysql_解决The total number of locks exceeds the lock table size错误

    在操作mysql数据库表时出现以下错误. 网上google搜索相关问题,发现一位外国牛人这么解释: If you're running an operation on a large number o ...

  7. MySQL解决[Err] 1206 - The total number of locks exceeds the lock table size问题

    MySQL解决[Err] 1206 - The total number of locks exceeds the lock table size问题 查看MySQL版本:mysql>show ...

  8. mysql 数据库缓存调优之解决The total number of locks exceeds the lock table size错误

    环境: mysql5.6.2  主从同步(备注:需操作主库和从库) 一.InnoDB表执行大批量数据的更新,插入,删除操作时会出现这个问题,需要调整InnoDB全局的innodb_buffer_poo ...

  9. 【MySQL笔记】mysql报错"ERROR 1206 (HY000): The total number of locks exceeds the lock table size"的解决方法

    step1:查看 1.1 Mysql命令行里输入"show engines:"查看innoddb数据引擎状态, 1.2 show variables "%_buffer% ...

随机推荐

  1. [汇编语言]-第九章 根据位移进行转移的jmp指令 段内短转移 段内近转移 段间转移(远转移) 转移的目的地址在指令中,在寄存器中,在内存中的jmp指令

    1- jmp为无条件转移指令,可以只修改IP, 也可以同时修改CS和IP jmp指令要给出两种信息: (1) 转移的目的地址 (2) 转移的距离(段间转移, 段内转移, 段内近转移) 2- 依据位移进 ...

  2. PHP解决网站高流量高并发问题

    首先,确认服务器硬件是否足够支持当前的流量. 普通的P4服务器一般最多能支持每天10万独立IP,如果访问量比这个还要大, 那么必须首先配置一台更高性能的专用服务器才能解决问题 ,否则怎么优化都不可能彻 ...

  3. 让Scrapy的Spider更通用

    1,引言 <Scrapy的架构初探>一文所讲的Spider是整个架构中最定制化的一个部件,Spider负责把网页内容提取出来,而不同数据采集目标的内容结构不一样,几乎需要为每一类网页都做定 ...

  4. Gartner Publishes 2014 Magic Quadrant for SIEM and Critical Capabilities for SIEM Reports

    http://securityintelligence.com/gartner-2014-magic-quadrant-siem-security/#.SzNnhshk https://www.net ...

  5. MEMS微加工技术

    MEMS的微加工有两种方法,一种是多层平面加工技术,还有一种是基于SOI的体加工技术. (一)多层平面加工技术 这种方法加工出来的结构有三层:作为主体的多晶硅层.作为暂时填充物的氧化物牺牲层以及多晶硅 ...

  6. ngrok首页、文档和下载 - Web服务安全通道 - 开源中国社区

    ngrok首页.文档和下载 - Web服务安全通道 - 开源中国社区      Web服务安全通道 ngrok 编辑/纠错    分享到     新浪微博腾讯微博    已用    +0    收藏 ...

  7. 聚类算法初探(六)OPTICS

    最近由于工作需要,对聚类算法做了一些相关的调研.现将搜集到的资料和自己对算法的一些理解整理如下,供大家参考. 另外在算法代码方面,我也做了一些实现(包括串行和并行),欢迎感兴趣的朋友探讨和交流. 第一 ...

  8. Do we need other languages other than C and C++?

    There were hundreds of or thousands of programming languages created since the invention of computer ...

  9. 依赖注入及AOP简述(十)——Web开发中常用Scope简介 .

    1.2.    Web开发中常用Scope简介 这里主要介绍基于Servlet的Web开发中常用的Scope. l        第一个比较常用的就是Application级Scope,通常我们会将一 ...

  10. DSOframer 无法正常加载的解决方案

    不了解 DSOframer 的朋友,可以先参考文章 DSOframer 的简单介绍和资源整理. 在使用 DSOframer 时,经常会碰到各种奇奇怪怪的问题,最常见的就是控件不能正常加载.大家可以按下 ...