Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to grant execute on specific stored procedure to user

I have created some stored procedure on a specific schema.

In this stored procedure, I want to grant execute privilege.

So I wrote that :

GRANT EXECUTE ON PROCEDURE schema_name.proc_name TO 'user_name';
GRANT SELECT ON mysql.proc to 'user_name';

The problem is : My user can see every stored procedure. I wish he could only see the procedure where he has the EXECUTE privilege.

Is there a way to achieve that ?

Thanks in advance.

like image 523
TriGerZ Avatar asked Jun 30 '14 15:06

TriGerZ


1 Answers

Yes... this works as expected if you don't grant the user the SELECT privilege on the mysql.proc table, either directly or indirectly, such as with GRANT SELECT ON *.* TO ...

Without SELECT permission on this table, a user can only see the existence of stored procedures and stored functions where they have other permissions, like EXECUTE.

Under the hood, the lack of SELECT on mysql.proc also prevents the user from seeing the procedures they don't have access to via the information_schema.routines pseudo-table.

You shouldn't need to GRANT SELECT ON mysql.proc to enable the user to execute procedures or functions... and if you do, then that seems like the question.

like image 168
Michael - sqlbot Avatar answered Oct 07 '22 09:10

Michael - sqlbot