Home > Database > Mysql Tutorial > body text

Detailed explanation of code examples about mysql create routine permissions

黄舟
Release: 2017-03-18 13:51:23
Original
1814 people have browsed it

The editor below will bring you some instructions on mysql create routine permissions. The editor thinks it is quite good, so I will share it with you now and give it as a reference for everyone. Let’s follow the editor and take a look

1. If the user has create routine permission, then he can create procedure | function.

2. If the user creates a procedure | function, then mysql will automatically grant it the alter routine and execute permissions on the procedure | function.

3. Example:

User root creates a spuser@'localhost' user and gives it the create procedure permission

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

Use spuser@'localhost' user to create A routine

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

delimiter ;
Copy after login

Check the permissions of spuser@'localhost' again

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'          |
+---------------------------------------------------------------------------------------------------------------+
Copy after login

The above is the detailed content of Detailed explanation of code examples about mysql create routine permissions. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!