---
name: "mysql_error"
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_error"
---

# mysql\_error(3)

### Name

mysql\_error - returns the last error message for the most recent function call

### Synopsis

-

  ```
  #include <mysql.h>
  const char * mysql_error(MYSQL * mysql);
  ```

### Description

Returns the last error message for the most recent function call that can succeed or fail. An empty string means no error occurred.

### Parameter

- •

  `mysql` is a connection identifier, which was previously allocated by **[mysql\_init(3)](/mysql_init/3.md)** and connected by **[mysql\_real\_connect(3)](/mysql_real_connect/3.md)**.

### Notes

- •

  Client error codes are listed in `errmsg.h` header file, server error codes are listed in `mysqld_error.h` header file of the server source distribution.

- •

  Client error messages can be obtained by calling **[mariadb\_get\_infov(3)](/mariadb_get_infov/3.md)** and passing the parameter `MARIADB_CLIENT_ERRORS`

### See also

- •

  **[mysql\_errno(3)](/mysql_errno/3.md)**

- •

  **[mysql\_sqlstate(3)](/mysql_sqlstate/3.md)**
