mysql 查看read only,MySQL read_only 与 super_read_only 之间的关系

目录super_read_only = 0, read_only=0

super_read_only=0, read_only=1

super_read_only=1, read_only=0

super_read_only=1, read_only=1

super_read_only = 0, read_only=0

super_read_only = 1, read_only=0

super_read_only = 0, read_only=1

super_read_only = 1, read_only=1

总结

read_only 表示是否允许普通用户写入。如果为on,表示禁止普通用户写入。

super_read_only 表示是否禁止超级用户写入,包括普通用户,即针对所有用户。

默认关闭。

如果打开 super_read_only,则read_only会自动打开。

如果关闭 read_only,则 super_read_only 会自动关闭。

下面做下测试。

super_read_only = 0, read_only=0

查看当前值:

>select @@super_read_only, @@read_only;

+-------------------+-------------+

| @@super_read_only | @@read_only |

+-------------------+-------------+

| 0 | 0 |

+-------------------+-------------+

1 row in set (0.01 sec)

设置super_read_only=1之后,查看read_only的变化。

>set global super_read_only=1;

Query OK, 0 rows affected (0.00 sec)

>select @@super_read_only, @@read_only;

+-------------------+-------------+

| @@super_read_only | @@read_only |

+-------------------+-------------+

| 1 | 1 |

+-------------------+-------------+

1 row in set (0.01 sec)

read_only变为1。

超级用户设置为只读后,自然普通用户也会设置只读。

super_read_only=0, read_only=1

查看当前值:

>select @@super_read_only, @@read_only;

+-------------------+-------------+

| @@super_read_only | @@read_only |

+-------------------+-------------+

| 0 | 1 |

+-------------------+-------------+

1 row in set (0.00 sec)

设置 super_read_only=1后, 查看read_only 变化。

>set global super_read_only=1;

Query OK, 0 rows affected (0.00 sec)

>select @@super_read_only, @@read_only;

+-------------------+-------------+

| @@super_read_only | @@read_only |

+-------------------+-------------+

| 1 | 1 |

+-------------------+-------------+

1 row in set (0.00 sec)

read_only无变化。

super_read_only=1, read_only=0

不存在这种情况。

super_read_only=1, read_only=1

查看当前值:

>select @@super_read_only, @@read_only;

+-------------------+-------------+

| @@super_read_only | @@read_only |

+-------------------+-------------+

| 1 | 1 |

+-------------------+-------------+

1 row in set (0.00 sec)

设置super_read_only = 0之后, 查看read_only变化。

>set global super_read_only=0;

Query OK, 0 rows affected (0.01 sec)

>select @@super_read_only, @@read_only;

+-------------------+-------------+

| @@super_read_only | @@read_only |

+-------------------+-------------+

| 0 | 1 |

+-------------------+-------------+

1 row in set (0.00 sec)

super_read_only = 0, read_only=0

查看当前值:

>select @@super_read_only, @@read_only;

+-------------------+-------------+

| @@super_read_only | @@read_only |

+-------------------+-------------+

| 0 | 0 |

+-------------------+-------------+

1 row in set (0.01 sec)

设置read_only=1之后,查看super_read_only 有无变化。

>set global read_only=1;

Query OK, 0 rows affected (0.00 sec)

>select @@super_read_only, @@read_only;

+-------------------+-------------+

| @@super_read_only | @@read_only |

+-------------------+-------------+

| 0 | 1 |

+-------------------+-------------+

1 row in set (0.00 sec)

super_read_only = 1, read_only=0

不存在这种情况。

super_read_only = 0, read_only=1

查看当前值:

>select @@super_read_only, @@read_only;

+-------------------+-------------+

| @@super_read_only | @@read_only |

+-------------------+-------------+

| 0 | 1 |

+-------------------+-------------+

1 row in set (0.00 sec)

设置 read_only=0后,查看super_read_only有无变化。

>set global read_only=0;

Query OK, 0 rows affected (0.00 sec)

>select @@super_read_only, @@read_only;

+-------------------+-------------+

| @@super_read_only | @@read_only |

+-------------------+-------------+

| 0 | 0 |

+-------------------+-------------+

1 row in set (0.01 sec)

super_read_only变为 0。

普通用户关闭只读,超级用户的只读(也包括普通用户)也自然会关闭只读。

super_read_only = 1, read_only=1

查看当前值:

>select @@super_read_only, @@read_only;

+-------------------+-------------+

| @@super_read_only | @@read_only |

+-------------------+-------------+

| 1 | 1 |

+-------------------+-------------+

1 row in set (0.01 sec)

设置read_only=0之后,查看 super_read_only的变化。

>set global read_only=0;

Query OK, 0 rows affected (0.00 sec)

>select @@super_read_only, @@read_only;

+-------------------+-------------+

| @@super_read_only | @@read_only |

+-------------------+-------------+

| 0 | 0 |

+-------------------+-------------+

1 row in set (0.01 sec)

super_read_only变为 0。

总结

关于 read_only 与 super_read_only之间的关系,实际上从其定义就可以明白。

基础很重要。

MySQL read_only 与 super_read_only 之间的关系

标签:sele   存在   mys   普通用户   contain   glob   class   head   设置

本条技术文章来源于互联网,如果无意侵犯您的权益请点击此处反馈版权投诉

本文系统来源:https://www.cnblogs.com/lanyangsh/p/14391471.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值