MySQL Variables super_read_only 数据库 参数变量解释及正确配置使用

本站中文解释

super_read_only参数是MySQL服务器用于只读状态的参数,可用于以下各种场景:

1.在备库运行MySQL服务器以保证数据库容灾:备库上设置super_read_only参数为ON,只允许服务器端运行应用程序,而不允许客户端连接查询。

2.在生产环境时控制DML查询:为了控制用户的DML查询,可以设置super_read_only参数为ON,仅允许某些用户执行更新操作。

3.用于运行唯读复制:MySQL 稳定版 5.7及之前的版本中,无法禁止binlog的写,而super_read_only参数的存在,可以方便的解决这一问题,使备库在只读模式下正常运行,这样就可以实现唯读复制。

设置super_read_only参数: 进入MySQL控制台,在mysql>提示符下执行以下两条命令:

SET GLOBAL super_read_only=1;

FLUSH PRIVILEGES;

官方英文解释

super_read_only

Command-Line Format --super-read-only[={OFF|ON}]
System Variable super_read_only
Scope Global
Dynamic Yes
Type Boolean
Default Value OFF

If the read_only system
variable is enabled, the server permits no client updates
except from users who have the
SUPER privilege. If the
super_read_only system
variable is also enabled, the server prohibits client updates
even from users who have SUPER.
See the description of the
read_only system variable for
a description of read-only mode and information about how
read_only and
super_read_only interact.

Client updates prevented when
super_read_only is enabled
include operations that do not necessarily appear to be
updates, such as CREATE FUNCTION (to
install a loadable function) and INSTALL
PLUGIN
. These operations are prohibited because they
involve changes to tables in the mysql
system database.

Changes to super_read_only on
a replication source server are not replicated to replica
servers. The value can be set on a replica independent of the
setting on the source.


数据运维技术 » MySQL Variables super_read_only 数据库 参数变量解释及正确配置使用