Database Transaction Processing exclusive lock under www.2cto.com make an experiment to verify the effect of the lock Terminal 1, first enter the transaction status and then run the following statement mysql> begin; Query OK, 0 rows affected (0.00 sec) mysql> select * from t1 where id = '3' for update; + ---- + -------- + --------------------- + ------------------- + | id | name | ctime | mtime | + ---- + -------- + hour + --------------------- + | 3 | test | 0000-00-00 00:00:00 | 13:05:41 | + ---- + -------- + -------------------- -+ --------------------- + 1 row in set (0.00 sec) Terminal 2: query the data in the table mysql> select * from t1; + ---- + -------- + --------------------- + ------------------- + | id | name | ctime | mtime | + ---- + -------- + hour + --------------------- + | 1 | neo | 0000-00-00 00:00:00 | 13:00:00 | 2 | zen | 0000-00-00 00:00:00 | 13:00:43 | 3 | test | 0000-00-00 00:00:00 | 13:05:41 | + -- -- + -------- + --------------------- + ------------------- + 3 rows in set (0.00 sec) Add "for update" to query non-lock record www.2cto.com mysql> select * from t1 where id = 2 for update; + ---- + ------ + upper + ------------------- + | id | name | ctime | mtime | + ---- + ------ + ----------------------- + ----------------- + | 2 | zen | 0000-00-00 00:00:00 | 13:00:43 | + ---- + ------ + ------------------- + ----- ---------------- + 1 row in set (0.00 sec) query locked records mysql> select * from t1 where id = 3 for update; ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction to query all records. Because the record contains the id = 3, query is not allowed. Mysql> select * from t1 for update; ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction test modification record mysql> UPDATE 'T1 'set' name' = 'testa' WHERE 'id' = 3; ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction prompt when ERROR 1205 (HY000) is not displayed, As long as commit and rollback are executed in Terminal 1. the statement in Terminal 2 will run.