MySQL – Preserve Execute Permissions for Procedure with ALTER PROCEDURE

MySQLpermissions

In MySQL you can not alter procedure rather you have to perform drop/create procedure to alter the body of the procedure. The problem is doing drop/create also removes the execute permissions given on that selected procedure.

Is there any way of giving permanent execute permissions that remains even after drop/create procedure.

A sample code to verify is as below

delimiter //
create procedure t1 ()
select 1;
//

grant execute on procedure t1 to test1@'%';

call t1() works well, but if you run the above code after doing drop procedure first it gives permissions error.

Any help is much appreciated

Best Answer

Best is to grant execute at the DB level:

grant execute on db.* to test1@'10.%'; (don't use %, too risk, use ip subnet) This way you don't need to grant permission in SP.