MySQL 赋予用户权限命令的简单格式可概括为:
- grant 权限 on 数据库对象 to 用户
- 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@'%'
- 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 create view on testdb.* to developer@'192.168.0.%';
- grant show view on testdb.* to developer@'192.168.0.%';
- 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 all privileges on testdb to dba@'localhost'
- grant all on *.* to dba@'localhost
- grant select on *.* to dba@localhost; -- dba 可以查询 MySQL 中所有数据库中的表。
- grant all on *.* to dba@localhost; -- dba 可以管理 MySQL 中的所有数据库
- grant select on testdb.* to dba@localhost; -- dba 可以查询 testdb 中的表。
- grant select, insert, update, delete on testdb.orders to dba@localhost;
- grant select(user_id,username) on smp.users to mo_user@'%' identified by '123345';
- grant select on smp.mo_sms to mo_user@'%' identified by '123345';
- grant select(id, se, rank) on testdb.apache_log to dba@localhost;
- grant execute on procedure testdb.pr_add to 'dba'@'localhost'
- grant execute on function testdb.fn_add to 'dba'@'localhost'
- show grants;
- show grants;
- grant all on *.* to dba@localhost;
- revoke all on *.* from dba@localhost;