Event Permissions
The EVENT privilege controls who can create, alter, and drop events. Events run with the DEFINER user's privileges by default.
The EVENT privilege controls who can create, alter, and drop events. Events run with the DEFINER user's privileges by default.
-- Grant event privilege to a user
GRANT EVENT ON mydb.* TO "app_user"@"localhost";
-- Show grants
SHOW GRANTS FOR "app_user"@"localhost";
-- Create event with specific definer
CREATE DEFINER = "admin"@"localhost" EVENT secure_cleanup
ON SCHEDULE EVERY 1 HOUR DO DELETE FROM sessions WHERE expired = 1;
-- Event runs with admin privileges, not the user who created it via app_user
The DEFINER runs the event code — use a dedicated service account with minimal required privileges.