增删改查的权限grant select on testdb.* to [email protected]‘%‘ grant insert on testdb.* to [email protected]‘%‘ grant update on testdb.* to [email protected]‘%‘ grant delete on testdb.* to [email protected]‘%‘grant select, insert, update, delete on testdb.* to [email protected]‘%‘ 所有权限 其中,关键字 “privileges” 可以省略。 grant all privileges on database_name.* to [email protected] identified by "000000"; grant 高级 DBA 管理 MySQL 中所有数据库的权限。grant all on *.* to [email protected]‘localhost‘ 创建修改,删除表的权限grant create on testdb.* to [email protected]‘192.168.0.%‘;grant alter on testdb.* to [email protected]‘192.168.0.%‘;grant drop on testdb.* to [email protected]‘192.168.0.%‘; 外键操作权限grant references on testdb.* to [email protected]‘192.168.0.%‘; 临时表权限grant create temporary tables on testdb.* to [email protected]‘192.168.0.%‘; 索引权限grant index on testdb.* to [email protected]‘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 [email protected];grant作用的可分多个层次 1.grant 整个 MySQL 服务器上 grant select on *.* to [email protected]; -- dba 可以查询 MySQL 中所有数据库中的表。 grant all on *.* to [email protected]; -- dba 可以管理 MySQL 中的所有数据库 2.grant 单个库 grant all on test.* to [email protected]; 3.grant单个表 grant all on test.tb1 to [email protected]; 4.grant 多个列 grant select(id,name) on test.tb1 to [email protected] 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 [email protected];
撤销权限用revoke 把to换成from
时间: 2024-12-09 17:36:22