Home>Article>Database> How to set mysql database to read-only

How to set mysql database to read-only

WBOY
WBOY Original
2022-05-27 16:21:15 5174browse

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.

How to set mysql database to read-only

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

How to set mysql database to read-only

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%";数据库

How to set mysql database to 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.

How to set mysql database to read-only

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!

Statement:
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