Documentation Home
MySQL 9.4 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 41.2Mb
PDF (A4) - 41.3Mb
Man Pages (TGZ) - 262.8Kb
Man Pages (Zip) - 368.8Kb
Info (Gzip) - 4.1Mb
Info (Zip) - 4.1Mb


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

27.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 account named as a routineDEFINER can see all routine properties, including its definition. The account thus has full access to the routine output as produced by:

  • For an account other than the account named as the routineDEFINER, access to routine properties depends on the privileges granted to the account:

    • With theSHOW_ROUTINE privilege or the globalSELECT privilege, the account can see all routine properties, including its definition.

    • With theCREATE ROUTINE,ALTER ROUTINE orEXECUTE privilege granted at a scope that includes the routine, the account can see all routine properties except its definition.