In mysql, you can use set global to set the database to read-only. The syntax is "set global read_only=1"; this statement needs to be executed under a user with root permissions. If you need to cancel the read-only permissions , just use this statement to set the value of "read_only" to 0.
The operating environment of this tutorial: windows10 system, mysql8.0.22 version, Dell G3 computer.
Set command:
mysql>set global read_only=1; #1是只读,0是读写
This statement needs to be executed successfully under a user with permissions such as root
mysql> show global variables like "%read_only%";数据库
If we want to solve the read-only permission, we can execute the same statement and set the value to 0.
read_only=0; The specific code is shown in the figure.
Recommended learning:mysql video tutorial
The above is the detailed content of How to set mysql database to read-only. For more information, please follow other related articles on the PHP Chinese website!