数据库系列-MySQL-角色用户

grant 权限 on 数据库对象 to 用户 
一、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@’%’ 
或者,用一条 mysql 命令来替代: 
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 普通 dba 管理某个 mysql 数据库的权限。 
grant all privileges on testdb to dba@’localhost’ 
其中,关键字 “privileges” 可以省略。


四、grant 高级 dba 管理 mysql 中所有数据库的权限。 
grant all on *.* to dba@’localhost’