Databases InterBase (29) MS-SQL (5) mysql (37) Oracle (1)
Exchange Links About this site Links to us 
|
Lock an entire mysql database with all its tables
11 comments. Current rating: (6 votes). Leave comments and/ or rate it.
Question: How can I lock my entire mysql database? And how can I lock a single table?
Answer: Go to the mysql shell and use the FLUSH command.
This clloses all open tables and locks all tables for all databases with a read lock until you execute UNLOCK TABLES. This is very convenient way to get backups.
 | |  | | FLUSH TABLES WITH READ LOCK;
UNLOCK TABLES; | |  | |  |
Comments:
|
anonymous from India
|
|
|
|
|
|
anonymous from Ukraine
|
|
|
|
thanks
|
2009-01-07, 08:41:54 (updated: 2009-01-07, 08:44:26) |
anonymous from France
|
 |
|
|
I guess you're talking about a filesystem backup, as you wouldn't need to lock anything if backing up the database.
|
|
anonymous from India
|
 |
|
|
|
|
anonymous from New Delhi, India
|
 |
|
|
Dear
How can i lock all the tables of a single database or to lock a particular table.
Thanks
Anil
|
|
anonymous
|
 |
|
|
lock tables db.* read;
|
|
anonymous
|
 |
|
|
|
2009-04-02, 06:59:29 (updated: 2009-04-02, 07:01:39) |
anonymous
|
 |
|
|
|
|
anonymous from Brazil
|
|
|
|
What u have to do to lock all tables...
Get all tables ( select * from information_schema.tables ) and put in a Cursor...
Iterate in cursor and lock each table... ( Lock Table X )
|
|
anonymous from United States
|
|
|
|
|
|
anonymous from United States
|
|
|
|
FLUSH TABLES WITH READ LOCK; works just fine in locking all the tables in a databse.
|
|