MySQL – Stored Procedure Requiring SUPER Permission

MySQLpermissionsstored-procedures

I'm trying to figure out a "safe" way of allowing a non-SUPER user to execute a specific command requiring SUPER privileges, i.e. SET SESSION binlog_format = 'MIXED'. I don't want to grant the user SUPER privileges for security reasons. Can this be accomplished using a stored procedure or any other method?

Best Answer

You can have stored procedures execute as the definer instead of the invoker:

CREATE DEFINER = 'admin'@'localhost' PROCEDURE p1()
SQL SECURITY DEFINER
BEGIN
  UPDATE t1 SET counter = counter + 1;
END;

See: Access Control for Stored Programs and Views