Some instructions on mysql create routine permissions

  • 2021-07-22 11:40:37
  • OfStack

1. If the user has create routine privileges, he can create procedure function.

2. If the user creates procedure function, mysql automatically grants it alter routine and execute permissions on procedure function.

3. Examples:

User root User creates an spuser @ 'localhost' user and gives it create procedure privileges


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

Use spuser @ 'localhost' user to create an routine


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

delimiter ;

View permissions for spuser @ 'localhost' one more time


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'          |
+---------------------------------------------------------------------------------------------------------------+

Related articles: