I have multiple mysql databases and I want to perform some administration tasks on a particular database. How do I ensure that no one else can connect to that database while the tasks in progress?
解决方案
Apparently, you can use the FLUSH command for this as such:
> FLUSH TABLES WITH READ LOCK;
and then
> UNLOCK TABLES;
to unlock the database again. Unsure if some setting needs to be set on the tables to allow a readlock. You can test this by trying to do a manual insert after the database is locked and if you get an error message about the table being locked, you know it worked.