<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. CSS3 设置 Table 隔行变色

    table tr:nth-child(odd){background:#F4F4F4;} table td:nth-child(even){color:#C00;}

  2. bzoj2015 [Usaco2010 Feb]Chocolate Giving

    Description Farmer John有B头奶牛(1<=B<=25000),有N(2*B<=N<=50000)个农场,编号1-N,有M(N-1<=M<=10 ...

  3. C# 导出CSV功能记录下

    异常问题1: 如 机构编号 导出城CSV后,前面的四个0000不显示了, 解决办法 输出格式变为 =" 异常问题2: PPMABAT01:/MABATAPS/usr/ma_batas > ...

  4. 使用Node.js快速搭建WebSocket server

    原文地址:http://my.oschina.net/yushulx/blog/309413 目录[-] 安装 服务端 客户端 参考 安装 ? 1 npm install ws 服务端 server. ...

  5. cocos2d-x 学习笔记一(概述)

    1.游戏-可控制的动画-连续的静态图像 2.关键帧驱动游戏 3.事件驱动型游戏 4.cocos2d-x 1.0 opengl-es 1.0;cocos2d-x 2.x opengl-es 2.0;co ...

  6. gmapping 学习

    为解决斜坡下gmapping定位的问题,开始关注gmapping. 先看到EAIPOT博客里关于gmapping的一个参数文件 <launch> <arg name="sc ...

  7. C++ STL源代码学习(map,set内部heap篇)

    stl_heap.h ///STL中使用的是大顶堆 /// Heap-manipulation functions: push_heap, pop_heap, make_heap, sort_heap ...

  8. 【线段树】【3-21个人赛】【同样的problemB】

    同一道题  http://blog.csdn.net/zy691357966/article/details/44680121 区间查询最大值 用线段树 比单调队列慢 #include <cst ...

  9. webapi拦截请求

    [AttributeUsage(AttributeTargets.Method)] public class WebApiSensitive : ActionFilterAttribute { pub ...

  10. MYSQL报Fatal error encountered during command execution.错误的解决方法

    {MySql.Data.MySqlClient.MySqlException (0x80004005): Fatal error encountered during command executio ...