What are you trying to do here? Locks in MySQL can be a little confusing if you make assumptions about what you think they do.
- A READ lock allows the session with the lock to read and other sessions to read but not write.
- A WRITE lock allows the session with the lock to read and write and other sessions no access.
The FLUSH TABLES
syntax doesn't allow you to specify a list of tables as well as acquiring a lock. FLUSH TABLES WITH READ LOCK
locks all tables. FLUSH TABLES <tables>
will flush those tables. There is some implicit locking involved in flushing tables as new writes cannot go to a table while it is being flushed but this implicit lock is released as soon as the flush completes.
If you want to lock specific tables with a write lock, LOCK TABLES <table> WRITE
is what you want. You can supply a comma-delimited list of tables here. If you want to lock all tables you will need to supply the entire list.