查看数据库的最大连接数
show VARIABLES like '%max_connections%'
set GLOBAL max_connections = 200
max_connections=151
查看是否开启缓存
show variables like '%query_cache_type%'
SET GLOBAL query_cache_size = 4000;
SET GLOBAL query_cache_size = 134217728;
注:MYISIM也叫非聚集索引
show VARIABLES like 'innodb_file_per_table'
set global innodb_file_per_table=off
1. lock table testmysam READ 启动另外一个session select * from
testmysam 可以查询
2. insert into testmysam value(2);
update testmysam set id=2 where id=1;
报错
3.在另外一个session中
insert into testmysam value(2); 等待
4.在同一个session中
insert into testdemo value(2,'2','3'); 报错
select * from testdemo ; 报错
5.在另外一个session中
insert into testdemo value(2,'2','3'); 成功
6.加索在同一个session 中 select s.* from testmysam s 报错
lock table 表名 as 别名 read;
查看 show status LIKE 'table_locks_waited' 表被锁过几次
注:myisim索引的共享读锁说白了 就是锁住了当前表,所有的读操作是可以的,但是更新插入操作是需要等待锁释放后才能操作
独占写锁则表示 其他的会话要操作当前表 ,必须要等到锁释放后才能操作,包括查询和更新
也可以用工具来修改
注:关于锁的理解可以在参考: https://blog.csdn.net/localhost01/article/details/78720727