Home > Database > Mysql Tutorial > body text

How to set table as read-only in mysql

青灯夜游
Release: 2022-01-04 16:03:31
Original
5641 people have browsed it

Setting method: 1. Execute the "mysql -u root -p" command and enter the password to log in to mysql; 2. Use the "use database name;" statement to select the specified database; 3. In the specified database, Use the "lock table data table name read;" statement to set the specified data table to read-only.

How to set table as read-only in mysql

The operating environment of this tutorial: windows7 system, mysql8 version, Dell G3 computer.

MySQL sets the database table to read-only

1. Log in to mysql:

mysql> mysql -u root -p
Copy after login

2. Select database

mysql> use test;
Database changed
Copy after login

When executing the select database statement, if the "Database changed" prompt appears, it means that the database selection is successful.

3. Set the table to read-only

mysql> lock table t_depart_info read;
Query OK, 0 rows affected (0.00 sec)
Copy after login

Test: insert data

How to set table as read-only in mysql

Command analysis:

  • Since t_depart_info is set to read-only, data cannot be inserted into it, so the screenshot is always loading requests...

[Related recommendations :mysql video tutorial

The above is the detailed content of How to set table as read-only in mysql. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template