zoukankan      html  css  js  c++  java
  • MySQL read_only 与 super_read_only 之间的关系

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

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

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

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

    下面做下测试。

    当super_read_only = 0, read_only=0,设置super_read_only=1

    查看当前值:

    >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,设置 super_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,设置super_read_only = 0

    查看当前值:

    >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,设置read_only=1

    查看当前值:

    >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,设置 read_only=0

    查看当前值:

    >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,设置read_only=0

    查看当前值:

    >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之间的关系,实际上从其定义就可以明白。

    基础很重要。

    Just try, don't shy.
  • 相关阅读:
    android 数据绑定(6)自定义绑定方法、双向数据绑定
    android apk瘦身(2) R8编译器:压缩代码、压缩资源、优化代码
    Kotlin 泛型
    android 数据绑定(5) kotlin 的binding bug
    android 数据绑定(4)实用特性及疑惑:使用控件、格式化@string/xxx、对象传递、双向数据绑定
    android apk瘦身(1) 使用矢量图 和 webp,去掉多余cpu架构的库文件
    android 数据绑定(3)自动更新UI
    android 数据绑定(2)绑定表达式
    android 数据绑定(1)Ativity、Fragment、Item绑定数据源
    react.js中render的return的坑
  • 原文地址:https://www.cnblogs.com/lanyangsh/p/14391471.html
Copyright © 2011-2022 走看看