FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Locking database with write access





badai
this is the step involved:

1. lock database so that nobody can write to it. read is allow

2. backup the database

3. update database (sync it with another database)

4. unlock database.

all is done with one php file. i will run this php as cron job.

my question:

how to lock database that only my script can write to it, while other script cannot write to it. all scripts (my script and other script) is accessing the database with the same credential (same login). my script is run via command line, while other script is run via http. is this even possible?
kv
Lock database
Code:

mysql_query("FLUSH TABLES WITH READ LOCK");


Unlock database
Code:

mysql_query("UNLOCK TABLES");
badai
your query won't allow me to write to any table. it will only allow me to read. so it's kind of useless.

anyway, i've solved my problem. the lock effect by connection, not by user.

and i don't even need to unlock my db. once my script end, it will end the connection and effectively end the locking.
kv
Can you post your solution please?
badai
LOCK TABLES table1[, table2, table2,....,tableN] WRITE

as I said, the lock effect by connection. so there is nothing special need to be done. if you know how to lock tables, you're good to go. i wasn't sure what will happen if another connection with same credential try to access the db before.

flush read lock is the same with lock read.

thanks anyway.
Related topics
help
Chatroom
Is there such a wsiwyg editor for sql
Typo installation
write rule on server
Cannot add txt to "longtext" column
Converting Access database to SQL server 2005
root access
What happened to Perl?
linux live CD with read write ntfs
How to set up a home FTP server
excel database
Dragonfly install tutorial
PHP Includes Problem
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.