views:

61

answers:

2

I want to lock everything--completely. Very simple. Just prevent things from changing!! Will this work?

use mydatabase;
flush tables with read lock;

...

unlock tables;

Edit: But, it has to be available for replication.

+1  A: 

This closes all open tables and locks all tables for all databases with a read lock until you execute UNLOCK TABLES.

NTulip
What does that mean...does it accomplish what I want?
TIMEX
maybe. clients that want to write will stall until the table is unlocked or they time out. in addition, any clients that want to read after a writer stalls will also stall. if you want all writes to error, you need to change the user permissions.
longneck
i agree = you should go with read only permissions for the username accessing the data. my suggestion works within the same transaction.
NTulip
+2  A: 

Wouldn't it be simpler to adjust the security for the user account accessing the database so that it only has read access?

David Lively
i like this approach
NTulip