> For the complete documentation index, see [llms.txt](https://mariadb.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_load_plugin.md).

# mysql\_load\_plugin

## Syntax

```bnf
#include <mysql.h>

struct st_mysql_client_plugin *
mysql_load_plugin(struct st_mysql *mysql, const char *name, int type,
                  int argc, ...);
```

## Parameters

| Parameter | Description                                                                                                                                                                                                                                        |
| --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `mysql`   | A connection handle previously allocated by [mysql\_init()](/docs/connectors/mariadb-connector-c/api-functions/mysql_init.md) and connected by [mysql\_real\_connect()](/docs/connectors/mariadb-connector-c/api-functions/mysql_real_connect.md). |
| `name`    | The name of the plugin to load.                                                                                                                                                                                                                    |
| `type`    | The plugin type, or `-1` to accept any type.                                                                                                                                                                                                       |
| `argc`    | The number of optional arguments that follow.                                                                                                                                                                                                      |
| `...`     | Optional arguments passed to the plugin's initialization function.                                                                                                                                                                                 |

## Description

`mysql_load_plugin` searches the client plugin directory for a plugin matching the given name and type, loads it, and calls its initialization function with any supplied arguments. If a plugin with that name is already loaded, the existing instance is returned without reloading.

## Valid Plugin Types

* `MYSQL_CLIENT_AUTHENTICATION_PLUGIN`
* `MARIADB_CLIENT_PVIO_PLUGIN`
* `MARIADB_CLIENT_REMOTEIO_PLUGIN`
* `MARIADB_CLIENT_CONNECTION_PLUGIN` or `MARIADB_CLIENT_COMPRESSION_PLUGIN`.

## Return Value

A pointer to the plugin handle, or `NULL` if an error occurred.

{% hint style="info" %}

* If the type of the plugin is not known, -1 needs to be specified for parameter type.
* The directory which contains the plugin can be specified either by the environment variable `MARIADB_PLUGIN_DIR` or it can be specified with [mysql\_optionsv()](/docs/connectors/mariadb-connector-c/api-functions/mysql_optionsv.md) using the option `MYSQL_PLUGIN_DIR`.
  {% endhint %}

## See Also

* [mysql\_optionsv()](/docs/connectors/mariadb-connector-c/api-functions/mysql_optionsv.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_load_plugin.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
