代码改变世界

数据库锁

2016-05-22 20:49  hduhans  阅读(125)  评论(0)    收藏  举报

解除表锁:

show processlist;

找到锁进程,kill id ;

 

秒杀数据库事务锁:

set autocommit=0;
begin work;
set @AGE = (select age from t_user where id=1 for update);
select 1;
select SLEEP(3),@AGE;
update t_user set age = @AGE +1 where id=1;

/*rollback;*/

commit;