• 每天进步一点点!

文章分类

推荐网站

常用手册

MySql的Grant命令【原创】

<<返回

2013-12-17 08:42:21

MySQL 赋予用户权限命令的简单格式可概括为:

grant 权限 on 数据库对象 to 用户

 

  • grant  普通数据用户,查询、插入、更新、删除 数据库中所有表数据的权利。
grant select, insert, update, delete on testdb.* to user@'%'

 

  • grant 创建、修改、删除 MySQL 数据表结构权限。
grant create,alter,drop on testdb.* to user@'192.168.0.%';

 

  • grant 操作 MySQL 外键权限。
grant references on testdb.* to user@'192.168.0.%';

 

  • grant 操作 MySQL 临时表权限。
grant create temporary tables on testdb.* to user@'192.168.0.%';

 

  • grant 操作 MySQL 索引权限。
grant index on testdb.* to user@'192.168.0.%';

 

  • grant 操作 MySQL 视图、查看视图源代码 权限。
grant create routine on testdb.* to user@'192.168.0.%'; 
grant alter  routine on testdb.* to user@'192.168.0.%'; 
grant execute        on testdb.* to user@'192.168.0.%';

 

  • grant 管理某个 MySQL 数据库的权限
grant all privileges on testdb to user@'localhost'

 

  • grant 管理 MySQL 中所有数据库的权限。
grant all on *.* to user@'localhost'

 

  • grant 查询数据库中指定列
grant select(user_id,username) on smp.users to user@'%' identified by '123345';

 

  • grant 作用在存储过程、函数上
grant execute on procedure testdb.pr_add to 'user'@'localhost'
grant execute on function testdb.fn_add to 'user'@'localhost'

 

  • 查看当前用户(自己)权限:
show grants;

 

  • 查看某个 MySQL 用户权限:
show grants for user@localhost;

 

  • 撤销已经赋予给 MySQL 用户权限的权限。revoke 跟 grant 的语法差不多,只需要把关键字 “to” 换成 “from” 即可:
grant  all on *.* to   user@localhost;
revoke all on *.* from user@localhost;

 

 

 

文章评论

  • 暂无评论

发表评论

昵称:

内容:

发表评论