MySQL - Table 'my_table' was not locked with Lock Tables

前端 未结 7 758
春和景丽
春和景丽 2020-12-29 18:41

I try and load tables via MySQL and get the following error?

MySQL said: Table \'cms\' was not locked with LOCK TABLES

Why does

7条回答
  •  悲&欢浪女
    2020-12-29 19:21

    If in one session, you locked one table but want to select from another table, you must either lock that table too or unlock all tables.

    mysql> LOCK TABLES t1 READ;
    mysql> SELECT COUNT(*) FROM t1;
    +----------+
    | COUNT(*) |
    +----------+
    |        3 |
    +----------+
    mysql> SELECT COUNT(*) FROM t2;
    ERROR 1100 (HY000): Table 't2' was not locked with LOCK TABLES
    

提交回复
热议问题