欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

关于mysql create routine 权限的一些说明

程序员文章站 2023-01-10 15:17:16
1、如果用户有create routine 权限那么他就可以创建procedure | function 。 2、如果用户创建了procedure | function...

1、如果用户有create routine 权限那么他就可以创建procedure | function 。

2、如果用户创建了procedure | function 那么mysql 会自动赋予它对procedure | function 的alter routine和execute 权限。

3、例子:

用户root用户创建一个spuser@'localhost'用户并对它赋予create procedure 权限

grant create routine on tempdb.* to spuser@'localhost' identified by '123456';

用spuser@'localhost'用户去创建一个routine

delimiter go
create procedure sp_hello_world()
begin
  select 'hello world';
end 
go

delimiter ;

再一次查看spuser@'localhost'的权限

mysql> show grants;
+---------------------------------------------------------------------------------------------------------------+
| grants for spuser@localhost                                          |
+---------------------------------------------------------------------------------------------------------------+
| grant usage on *.* to 'spuser'@'localhost' identified by password '*6bb4837eb74329105ee4568dda7dc67ed2ca2ad9' |
| grant create routine on `tempdb`.* to 'spuser'@'localhost'                          |
| grant execute, alter routine on procedure `tempdb`.`sp_hello_world` to 'spuser'@'localhost'          |
+---------------------------------------------------------------------------------------------------------------+

以上这篇关于mysql create routine 权限的一些说明就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。