### 5.7.1 Installing and Uninstalling Loadable Functions

[]()[]()[]()[]()

 Loadable functions, as the name implies, must be loaded into the server before they can be used. MySQL supports automatic function loading during server startup and manual loading thereafter.

 While a loadable function is loaded, information about it is available as described in [Section 5.7.2, “Obtaining Information About Loadable Functions”](obtaining-loadable-function-information.html).

* [Installing Loadable Functions](function-loading.html#loadable-function-installing)

* [Uninstalling Loadable Functions](function-loading.html#loadable-function-uninstalling)

* [Reinstalling or Upgrading Loadable Functions](function-loading.html#loadable-function-upgrading)

#### Installing Loadable Functions

 To load a loadable function manually, use the [`CREATE FUNCTION`](create-function-loadable.html) statement. For example:

```
CREATE FUNCTION metaphon
  RETURNS STRING
  SONAME 'udf_example.so';
```

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

[`CREATE FUNCTION`](create-function-loadable.html) has these effects:

* It loads the function into the server to make it available immediately.

* It registers the function in the `mysql.func` system table to make it persistent across server restarts. For this reason, [`CREATE FUNCTION`](create-function-loadable.html) requires the [`INSERT`](privileges-provided.html#priv_insert) privilege for the `mysql` system database.

* It adds the function to the Performance Schema [`user_defined_functions`](performance-schema-user-defined-functions-table.html) table that provides runtime information about installed loadable functions. See [Section 5.7.2, “Obtaining Information About Loadable Functions”](obtaining-loadable-function-information.html).

 Automatic loading of loadable functions occurs during the normal server startup sequence:

* Functions registered in the `mysql.func` table are installed.

* Components or plugins that are installed at startup may automatically install related functions.

* Automatic function installation adds the functions to the Performance Schema [`user_defined_functions`](performance-schema-user-defined-functions-table.html) table that provides runtime information about installed functions.

 If the server is started with the [`--skip-grant-tables`](server-options.html#option_mysqld_skip-grant-tables) option, functions registered in the `mysql.func` table are not loaded and are unavailable. This does not apply to functions installed automatically by a component or plugin.

#### Uninstalling Loadable Functions

 To remove a loadable function, use the [`DROP FUNCTION`](drop-function-loadable.html) statement. For example:

```
DROP FUNCTION metaphon;
```

[`DROP FUNCTION`](drop-function-loadable.html) has these effects:

* It unloads the function to make it unavailable.

* It removes the function from the `mysql.func` system table. For this reason, [`DROP FUNCTION`](drop-function-loadable.html) requires the [`DELETE`](privileges-provided.html#priv_delete) privilege for the `mysql` system database. With the function no longer registered in the `mysql.func` table, the server does not load the function during subsequent restarts.

* It removes the function from the Performance Schema [`user_defined_functions`](performance-schema-user-defined-functions-table.html) table that provides runtime information about installed loadable functions.

[`DROP FUNCTION`](drop-function-loadable.html) cannot be used to drop a loadable function that is installed automatically by components or plugins rather than by using [`CREATE FUNCTION`](create-function-loadable.html). Such a function is also dropped automatically, when the component or plugin that installed it is uninstalled.

#### Reinstalling or Upgrading Loadable Functions

 To reinstall or upgrade the shared library associated with a loadable function, issue a [`DROP FUNCTION`](drop-function-loadable.html) statement, upgrade the shared library, and then issue a [`CREATE FUNCTION`](create-function-loadable.html) statement. If you upgrade the shared library first and then use [`DROP FUNCTION`](drop-function-loadable.html), the server may unexpectedly shut down.

