FLUSH TABLES WITH READ LOCK 锁全局

[root@wx03 ~]# cat a3.sh 
mysql -uroot -p1234567<<eof
use scan;
FLUSH TABLES WITH READ LOCK;
system sleep 200;
exit;
eof 

mysql> use scan;
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 t1;
+-----+
| c1  |
+-----+
| 100 |
+-----+
1 row in set (0.00 sec)



mysql> insert into t1 values(200);




^CCtrl-C -- sending "KILL QUERY 13208" to server ...
Ctrl-C -- query aborted.
ERROR 1317 (70100): Query execution was interrupted
mysql> use DEVOPS;
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> insert into t1 values(99999,'aaa');

原文地址:https://www.cnblogs.com/zhaoyangjian724/p/6199563.html