• mysql 从设置只读


    read-only
    该选项限制普通用户只有select权限
    
    --read_only         Make all non-temporary tables read-only, with the 
                                   exception for replication (slave) threads and users with 
                                   the SUPER privileg
    
    使所有的非temporary表为只读,除了复制的threads和超级用户
    
    超级用户:
    SUPER privilege :
    
    The SUPER privilege enables an account to use CHANGE MASTER TO , KILL or mysqladmin kill to kill threads belonging to other accounts (you can always kill your own threads), PURGE BINARY LOGS , 
    
    configuration changes using SET GLOBAL to modify global system variables, the mysqladmin debug command, enabling or disabling logging, performing updates even if the read_only system variable is 
    
    enabled, starting and stopping replication on slave servers, specification of any account in the DEFINER attribute of stored programs and views, and enables you to connect (once) even if the 
    
    connection limit controlled by the max_connections system variable is reached.
    
    To create or alter stored routines if binary logging is enabled, you may also need the SUPER privilege, as described in Section 18.6, “Binary Logging of Stored Programs” 
    
    
    超级权限可以让一个账户使用CHANGE MASTER TO ,KILL或者mysqladmin kill 来kill 进程属于另外的账户(你也可以kill 你自己的threads),PURGE BINARY LOGS,
    
    配置改变使用SET GLOBAL 来修改全局系统变量,mysqladmin debug 命令,启用或者关闭logging,执行更新 甚至read_only 系统变量是启用的,启动和关闭复制在slave servers上,
    
    
    指定任何账户在存储程序和视图的定义属性。
    
    
    
    
    
    
    
    测试:
    slave:/etc# mysql -uzjzc_app -p1234567
    
    1.对应用用户无法写入和修改
    mysql> use zjzc;
    Reading table information for completion of table and column names
    You can turn off this feature to get a quicker startup with -A
    
    Database changed
    mysql> select * from test;
    +------+
    | id   |
    +------+
    |    1 |
    |    2 |
    |    3 |
    +------+
    3 rows in set (0.00 sec)
    
    mysql> insert into test values(4);
    ERROR 1290 (HY000): The MySQL server is running with the --read-only option so it cannot execute this statement
    
    此时zjzc_app用户 不能对表test进行插入
    
    2.对复制用户不影响
    mysql> select * from test;
    +------+
    | id   |
    +------+
    |    1 |
    |    2 |
    |    3 |
    +------+
    3 rows in set (0.00 sec)
    
    mysql>  select * from test;
    +------+
    | id   |
    +------+
    |    1 |
    |    2 |
    |    3 |
    |  100 |
    +------+
    4 rows in set (0.00 sec)
    
    
    
    3.对root用户不影响

  • 相关阅读:
    MATLAB读取文件——从非常规文本文件中读取数据
    注意——CAN通信设备控制
    硬件——USB传输速度和物理接口
    STM32F4-浮点DSP库的MDK开发环境的设置
    CRC校验
    蓝牙串口使用心得
    Mysql 层级、执行顺序、执行计划分析
    讲一讲垃圾回收算法
    【转】Java中的新生代、老年代、永久代和各种GC
    工具链接
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13351605.html
Copyright © 2020-2023  润新知