Lock all MySQL databases

Lock a database:
$ mysql -u user -p
mysql> FLUSH TABLES WITH READ LOCK;
This closes all open tables and locks all tables for all databases with a read lock until you execute UNLOCK TABLES.

Unlock:
mysql> UNLOCK TABLES;

(to lock a single table: LOCK TABLES table READ;)

Leave a Reply