How do I lock a MySQL DATABASE so that write/read/update/delete ..everything is locked?
I want to lock everything--completely. Very simple. Just prevent things from changing!! Will this work?
use mydatabase;开发者_StackOverflow
flush tables with read lock;
...
unlock tables;
Edit: But, it has to be available for replication.
Wouldn't it be simpler to adjust the security for the user account accessing the database so that it only has read access?
This closes all open tables and locks all tables for all databases with a read lock until you execute UNLOCK TABLES.
精彩评论