CREATE ROUTINE, ALTER ROUTINE, EXECUTE和GRANT权限适用于已存储的子程序。这些权限可以被授予为全局层级和数据库层级。而且,除了CREATE ROUTINE外,这些权限可以被授予为子程序层级,并存储在mysql.procs_priv表中
补充知识:
1、全局层级测试
创建一个测试账号test,授予全局层级的权限。如下所示:
mysql> set global validate_password_policy=0; mysql> grant select,insert on *.* to test@'%' identified by 'test'; mysql> flush privileges; mysql中有什么权限
用下面两种方式查询授予test的权限。如下所示:
mysql> show grants for test; mysql> select * from mysql.user where user='test'G;
2、数据库层级测试
创建一个测试账号test,授予数据库层级的权限。如下所示:
mysql> drop user test; mysql> grant select,insert,update,delete on jpcpdb.* to test@'%' identified by 'test@123'; mysql> select * from mysql.user where user='test'G; --可以看到无任何授权。 mysql> show grants for test; mysql> select * from mysql.db where user='test'G;
3、表层级测试
创建一个测试账号test,授予表层级的权限。如下所示:
mysql> drop user test; mysql> flush privileges; mysql> grant all on jpcpdb.user to test@'%' identified by 'test@123'; mysql> show grants for test; mysql> select * from mysql.tables_privG;
4、列层级测试
创建一个测试账号test,授予列层级的权限。如下所示:
mysql> drop user test; mysql> flush privileges; mysql> grant select (id, name) on jpcpdb.user to test@'%' identified by 'test@123'; mysql> flush privileges; mysql> select * from mysql.columns_priv; mysql> show grants for test;
5、子程序层级测试
创建一个测试账号test,授子程序层级的权限。如下所示:
mysql> DROP PROCEDURE IF EXISTS PRC_TEST; mysql> DELIMITER // mysql> CREATE PROCEDURE PRC_TEST() -> BEGIN -> SELECT * FROM user; -> END // mysql> DELIMITER ; mysql> grant execute on procedure jpcpdb.PRC_TEST to test@'%' identified by 'test@123'; mysql> flush privileges; mysql> show grants for test; mysql> select * from mysql.procs_priv where User='test';mysql中有什么权限