---
name: "mysql_init"
section: "3"
platform: "linux"
package: "mariadb"
version: "13.0.2-2"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/mysql_init"
---

# mysql\_init(3)

### Name

mysql\_init - Prepares and initializes a `MYSQL` structure

### Synopsis

-

  ```
  #include <mysql.h>
  MYSQL *mysql_init(MYSQL *mysql);
  ```

### Description

Prepares and initializes a `MYSQL` structure to be used with **[mysql\_real\_connect(3)](/mysql_real_connect/3.md)**. If an address of a `MYSQL` structure was passed as parameter, the structure will be initialized, if `NULL` was passed, a new structure will be allocated and initialized.

**Notes:** \* If parameter `mysql` is not `NULL` **[mysql\_close(3)](/mysql_close/3.md)** API function will not release the memory \* Any subsequent calls to any function (except **[mysql\_optionsv(3)](/mysql_optionsv/3.md)** will fail until **[mysql\_real\_connect(3)](/mysql_real_connect/3.md)** was called. \* Memory allocated by `mysql_init()` must be freed with **[mysql\_close(3)](/mysql_close/3.md)**.

### Return value

The `mysql_init()` function returns an address of a `MYSQL` structure, or NULL in case of memory allcation error.

### See also

- •

  **[mysql\_close(3)](/mysql_close/3.md)**

- •

  **[mysql\_optionsv(3)](/mysql_optionsv/3.md)**
