# mysql\_reset\_connection

## Syntax

```c
int mysql_reset_connection(MYSQL * mysql);
```

* `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

Resets the current connection and clears session state. Similar to [mysql\_change\_user()](/docs/connectors/mariadb-connector-c/api-functions/mysql_change_user.md) or [mariadb\_reconnect()](/docs/connectors/mariadb-connector-c/api-functions/mariadb_reconnect.md), `mysql_reset_connection()` resets session status, but without disconnecting, opening, or reauthenticating.

On client side `mysql_reset_connection()`

* clears pending or unprocessed result sets
* clears status like `affected_rows`, info or `last_insert_id`
* invalidates active prepared statements

On server side `mysql_reset_connection()`

* drops temporary table(s)
* rollbacks active transaction
* resets auto commit mode
* releases table locks
* initializes session variables (and sets them to the value of corresponding global variables)
* closes active prepared statements
* clears user variables

Returns zero on success, non-zero if an error occurred.

This function was added in MariaDB Connector/C 3.0.0.

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


---

# Agent Instructions: 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_reset_connection.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.
