mysql grant select()_mysql grant命令

增删改查的权限

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

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

所有权限 其中,关键字 “privileges” 可以省略。

grant all privileges on database_name.* to user1@localhost identified by "000000";

grant 高级 DBA 管理 MySQL 中所有数据库的权限。

grant all on *.* to dba@'localhost'

创建修改,删除表的权限

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 references on testdb.* to developer@'192.168.0.%';

临时表权限

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

索引权限

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

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

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

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

grant 作用在表中的列上

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

grant作用的可分多个层次

1.grant 整个 MySQL 服务器上

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

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

2.grant 单个库

grant all    on test.* to dba@localhost;

3.grant单个表

grant all    on test.tb1 to dba@localhost;

4.grant 多个列

grant select(id,name) on test.tb1 to dba@localhost

5.grant 存储过程、函数

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

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

查看当前用户(自己)权限:

show grants;

查看其他 MySQL 用户权限:

show grants for dba@localhost;

撤销权限用revoke 把to换成from

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值