Documentation Home
MySQL 5.7 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 35.1Mb
PDF (A4) - 35.2Mb
Man Pages (TGZ) - 256.4Kb
Man Pages (Zip) - 361.2Kb
Info (Gzip) - 3.4Mb
Info (Zip) - 3.4Mb
Excerpts from this Manual

MySQL 5.7 Reference Manual  / ...  / Stored Objects  / Using Stored Routines  /  Stored Routines and MySQL Privileges

23.2.2 Stored Routines and MySQL Privileges

The MySQL grant system takes stored routines into account as follows:

  • TheCREATE ROUTINE privilege is needed to create stored routines.

  • TheALTER ROUTINE privilege is needed to alter or drop stored routines. This privilege is granted automatically to the creator of a routine if necessary, and dropped from the creator when the routine is dropped.

  • TheEXECUTE privilege is required to execute stored routines. However, this privilege is granted automatically to the creator of a routine if necessary (and dropped from the creator when the routine is dropped). Also, the defaultSQL SECURITY characteristic for a routine isDEFINER, which enables users who have access to the database with which the routine is associated to execute the routine.

  • If theautomatic_sp_privileges system variable is 0, theEXECUTE andALTER ROUTINE privileges are not automatically granted to and dropped from the routine creator.

  • The creator of a routine is the account used to execute theCREATE statement for it. This might not be the same as the account named as theDEFINER in the routine definition.

The server manipulates themysql.proc table in response to statements that create, alter, or drop stored routines. Manual manipulation of this table is not supported.