I use mysqldump for MySQL Backup.
mysqldump --lock-tables....
The DB is about 2GB, hence mysqldump takes a long time. If anyone tries to access the DB during backup, I would like to flash a message saying "the DB is being backe开发者_StackOverflowd-up, please return back after 10 minutes"
My questions is using PHP script, how can I check if mysql table is locked or not.
Thank you in advance.
Best regards, Sanjay
Prefer method will be setup replication,
and mysqldump on the slave instead on master (assuming only master is serving requests)
So, you never experiencing downtime
If you have both read/write lock you can write a php script that try to access/write in a table, if it is locked the MySQL server will rise an error and you will be able to evaluate the code and send a message if the error is because the tables are locked.
HTH!
EDIT: You can take a look of the MySQL GET_LOCK function
精彩评论