> 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/mariadb_reconnect.md).

# mariadb\_reconnect

## Syntax

```c
my_bool  mariadb_reconnect(MYSQL * mysql)
```

## Parameter

* `mysql` - a mysql handle, which was previously allocated by [mysql\_init()](/docs/connectors/mariadb-connector-c/api-functions/mysql_init.md) or [mysql\_real\_connect()](/docs/connectors/mariadb-connector-c/api-functions/mysql_real_connect.md).

## 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()](/docs/connectors/mariadb-connector-c/api-functions/mysql_real_connect.md).

## Return Value

The function will return 0 on success. The function will return an error, if the option `MYSQL_OPT_RECONNECT` wasn't specified before.

## History

This function was added in Connector/C 3.0.

## See Also

* [mysql\_real\_connect()](/docs/connectors/mariadb-connector-c/api-functions/mysql_real_connect.md)
* [mysql\_options()](/docs/connectors/mariadb-connector-c/api-functions/mysql_options.md)

{% @marketo/form formId="4316" %}
