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用户不影响

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

scan724

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值