# mariadb\_reconnect

## Syntax

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

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

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

The function will return 0 on sucess.

The function will return an error, if the option MYSQL\_OPT\_RECONNECT wasn't specified before.

This function was added in Connector/C 3.0.

## See also

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

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