mysql关于grant与revoke的详细教程_revoke all privileges from

先自我介绍一下,小编浙江大学毕业,去过华为、字节跳动等大厂,目前阿里P7

深知大多数程序员,想要提升技能,往往是自己摸索成长,但自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!

因此收集整理了一份《2024年最新软件测试全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友。
img
img
img
img
img

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上软件测试知识点,真正体系化!

由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新

如果你需要这些资料,可以添加V获取:vip1024b (备注软件测试)
img

正文

5,特定的存储过程

user表中host列的值的意义

%              
匹配所有主机

localhost    
localhost不会被解析成IP地址,直接通过UNIXsocket连接

127.0.0.1      
会通过TCP/IP协议连接,并且只能在本机访问;

::1                 
::1就是兼容支持ipv6的,表示同ipv4的127.0.0.1

使用案例:

grant 普通数据用户,查询、插入、更新、删除 数据库中所有表数据的权利。

grant select, insert, update, delete on testdb.* to common_user@’%’

grant 数据库开发人员,创建表、索引、视图、存储过程、函数。。。等权限。

grant 创建、修改、删除 MySQL 数据表结构权限。

grant create on testdb.* to developer@’192.168.0.%’;

grant alter on testdb.* to developer@’192.168.0.%’;

grant drop on testdb.* to developer@’192.168.0.%’;

grant 操作 MySQL 外键权限。

grant references on testdb.* to developer@’192.168.0.%’;

grant 操作 MySQL 临时表权限。

grant create temporary tables on testdb.* to developer@’192.168.0.%’;

grant 操作 MySQL 索引权限。

grant index on testdb.* to developer@’192.168.0.%’;

grant 操作 MySQL 视图、查看视图源代码 权限。

grant create view on testdb.* to developer@’192.168.0.%’;

grant show view on testdb.* to developer@’192.168.0.%’;

grant 操作 MySQL 存储过程、函数 权限。

grant create routine on testdb.* to developer@’192.168.0.%’; – now, can show procedure status

grant alter routine on testdb.* to developer@’192.168.0.%’; – now, you can drop a procedure

grant execute on testdb.* to developer@’192.168.0.%’;

grant 作用在整个 MySQL 服务器上:

grant select on *.* to dba@localhost; – dba 可以查询 MySQL 中所有数据库中的表。

grant all on *.* to dba@localhost; – dba 可以管理 MySQL 中的所有数据库

grant 作用在单个数据库上:

grant select on testdb.* to dba@localhost; – dba 可以查询 testdb 中的表。

grant 作用在单个数据表上:

grant select, insert, update, delete on testdb.orders to dba@localhost;

grant 作用在表中的列上:

grant select(id, se, rank) on testdb.apache_log to dba@localhost;

grant 作用在存储过程、函数上:

grant execute on procedure testdb.pr_add to ’dba’@’localhost’

grant execute on function testdb.fn_add to ’dba’@’localhost’

注意:修改完权限以后 一定要刷新服务,或者重启服务,刷新服务用:FLUSH PRIVILEGES

同理:revoke英文文档如下:

Introduction to the MySQL REVOKE Statement

In order to revoke privileges from a user account, you use the MySQL REVOKE statement. MySQL allows you to revoke one or more privileges or all privileges from a user.

The following illustrates the syntax of revoking specific privileges from a user:

1

2

3

4

|

REVOKE
privilege_type
[(column_list)]

[,
priv_type
[(column_list)]]…

ON
[object_type]
privilege_level

FROM

user
[,

user]…

|

Let’s examine the MySQL REVOKE statement in more detail.

  • First, specify a list of privileges that you want to revoke from a user right after the REVOKE keyword. You need to separate privileges by commas.
  • Second, specify the privilege level at which privileges is revoked in the ON clause .
  • Third, specify the user account that you want to revoke the privileges in the FROM clause.

Note that to revoke privileges from a user account, you must have GRANT OPTION privilege and the privileges that you are revoking.

To revoke all privileges from a user, you use the following form of the REVOKE statement:

1

|

REVOKE ALL PRIVILEGES,

GRANT OPTION

FROM

user
[,

user]…

|

To execute the REVOKE ALL statement , you must have the global CREATE USER privilege or the UPDATEprivilege for the mysql database.

To revoke proxy user, you use the REVOKE PROXY command as follows:

1

|

REVOKE PROXY ON

user

FROM

user
[,

user]…

|

A proxy user is a valid user in MySQL who can impersonate another user, therefore, the proxy user has all privileges of the user that it impersonates.

Before revoking privileges of a user, it is good practice to check if the user has the privileges by using theSHOW GRANTS statement as follows:

1

|

SHOW

GRANTS

FOR

user;

|

使用案例:
//查看rfc用户的权限

SHOWGRANTSFORrfc;

//MySQL返回如下结果:

GRANTSELECT,UPDATE,DELETEON’classicmodels’.*TO’rfc’@‘%’

//为rfc用户指定密码

CREATE USERIF EXISTSrfcIDENTIFIED BY’dolphin’;

//授权

GRANTSELECT,UPDATE,DELETEON  classicmodels.*TOrfc;

//解除 rfc用户的更新、删除权限

REVOKE

UPDATE,

DELETE

ON
classicmodels.*

FROM
rfc;

|

//查看rfc的权限

SHOWGRANTSFOR’rfc’@‘localhost’;

//返回结果:

GRANTSELECTON’classicmodels’.*TO’rfc’@‘%’

//解除rfc所有权限及grant

REVOKE ALL PRIVILEGES,GRANT OPTIONFROMrfc;

//查看rfc权限

SHOWGRANTSFOR’rfc’@‘localhost’;

//返回结果

GRANT

USAGE

ON
*.*

TO

‘rfc’@
‘%’

|

网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。

需要这份系统化的资料的朋友,可以添加V获取:vip1024b (备注软件测试)
img

一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!
LEGES,GRANT OPTIONFROMrfc;

//查看rfc权限

SHOWGRANTSFOR’rfc’@‘localhost’;

//返回结果

GRANT

USAGE

ON
*.*

TO

‘rfc’@
‘%’

|

网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。

需要这份系统化的资料的朋友,可以添加V获取:vip1024b (备注软件测试)
[外链图片转存中…(img-hP05xC9p-1713337868790)]

一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值