Documentation Home
MySQL 8.0 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 46.9Mb
PDF (A4) - 47.0Mb
PDF (RPM) - 42.3Mb
HTML Download (TGZ) - 10.8Mb
HTML Download (Zip) - 10.9Mb
HTML Download (RPM) - 9.3Mb
Man Pages (TGZ) - 226.1Kb
Man Pages (Zip) - 331.6Kb
Info (Gzip) - 4.2Mb
Info (Zip) - 4.2Mb
Excerpts from this Manual

MySQL 8.0 Reference Manual  /  ...  /  Installing and Uninstalling User-Defined Functions

5.7.1 Installing and Uninstalling User-Defined Functions

User-defined functions (UDFs) must be loaded into the server before they can be used. MySQL supports UDF loading at runtime.

To load a UDF, use the CREATE FUNCTION statement. For example:

  SONAME '';

The UDF file base name depends on your platform. Common suffixes are .so for Unix and Unix-like systems, .dll for Windows.

While a UDF is loaded, information about it is available from the Performance Schema user_defined_functions table. See Section 5.7.2, “Obtaining User-Defined Function Information”.

The statement also registers the UDF in the mysql.func system table to cause the server to load it on subsequent restarts. For this reason, CREATE FUNCTION requires the INSERT privilege for the mysql database.

To remove a UDF, use the DROP FUNCTION statement. For example:


CREATE FUNCTION unloads the UDF and removes it from the mysql.func system table. For this reason, DROP FUNCTION statement requires the DELETE privilege for the mysql database. With the UDF no longer registered in the table, the server does not load the UDF automatically for subsequent restarts.

You cannnot use CREATE FUNCTION to reinstall a function that has previously been installed. To reinstall a function, first remove it with DROP FUNCTION, then install it again with CREATE FUNCTION. You would need to do this, for example, if you upgrade to a new version of MySQL that provides an updated implementation of the function, or you recompile a new version of a function that you have written. Otherwise, the server continues to use the old version.

If the server is started with the --skip-grant-tables option, it does not consult the mysql.func table and does not load the UDFs listed there.