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

# mariadb\_reconnect(3)

### Name

mariadb\_reconnect - reconnects to a server

### Synopsis

-

  ```
  #include <mysql.h>
  my_bool  mariadb_reconnect(MYSQL * mysql)
  ```

### Description

`mariadb_reconnect()` tries to reconnect to a server in case the connection died due to timeout or other errors. It uses the same credentials which were specified in **[mysql\_real\_connect(3)](/mysql_real_connect/3.md)**.

### Return value

The function will return 0 on success, a non zero value on error

**Note**: The function will return an error, if the option `MYSQL_OPT_RECONNECT` wasn’t set before.

### History

`mariadb_reconnect()` was added in MariaDB Connector/C 3.0

### See also

- •

  **[mysql\_real\_connect(3)](/mysql_real_connect/3.md)**

- •

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