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.
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
2. Select database
mysql> use test; Database changed
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)
Test: insert data
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!