Home > php教程 > php手册 > 如何锁定MYSQL数据表

如何锁定MYSQL数据表

WBOY
Release: 2016-06-13 10:05:11
Original
1145 people have browsed it

在进行数据表检查或修补时,可以先将数据表锁定,可确保数据表的安全:
mysql>LOCK TABLE tbl_name READ;
mysql>FLUSH TABLES;
将数据表锁定后再进行检查或修补的工作。完成后再解除锁定:
mysql>UNLOCK TABLES;
//LOCK TABLE tbl_name READ表示要锁定成只读状态,在这个状态下用户只能读取数据表,不能写入。
LOCK TABLE tbl_name WRITE则是更严格的锁定,用户不能读取也不能写入。

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template