How to exclusive lock mysql database?

后端 未结 3 1532
予麋鹿
予麋鹿 2021-01-17 22:56

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

3条回答
  •  情深已故
    2021-01-17 23:00

    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.

    More information on FLUSH command

提交回复
热议问题