如何使用mysql的grant命令(详解)

grant命令的基本格式

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

实例一:在任意ip地址登陆的common_user用户可以对testdb数据库里的数据进行查询操作、插入操作、更新操作、删除操作

1 grant select on testdb.* to common_user@'%'//有查询数据的权限
2 grant insert on testdb.* to common_user@'%'//有出入数据的权限
3 grant update on testdb.* to common_user@'%'//有更新数据的权限
4 grant delete on testdb.* to common_user@'%'//有删除数据的权限

以上命令等价以下命令。

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

实例二:在ip为192.168.0.1到192.168.0.255之间登陆的developer用户可以对testdb数据库里的表进行创建、修改、删除操作

1 grant create on testdb.* to developer@'192.168.0.%';//有创建表的权限
2 grant alter  on testdb.* to developer@'192.168.0.%';//有修改表的权限
3 grant drop   on testdb.* to developer@'192.168.0.%';//有删除表的权限

 

参考网址:http://www.cnblogs.com/hcbin/archive/2010/04/23/1718379.html

 

posted on 2015-01-09 17:56  sustudy  阅读(1251)  评论(0编辑  收藏  举报

导航