This documentation is for an older version. If you're using the most current version, select the documentation for that version with the version switch in the upper right corner of the online documentation, or by downloading a newer PDF or EPUB file.

Chapter 20 Connectors and APIs

Table of Contents

20.1 MySQL Connector/ODBC
20.2 MySQL Connector/Net
20.3 MySQL Connector/J
20.4 MySQL Connector/C
20.5 libmysqld, the Embedded MySQL Server Library
20.6 MySQL C API
20.6.1 MySQL C API Implementations
20.6.2 Simultaneous MySQL Server and Connector/C Installations
20.6.3 Example C API Client Programs
20.6.4 Building and Running C API Client Programs
20.6.5 C API Data Structures
20.6.6 C API Function Overview
20.6.7 C API Function Descriptions
20.6.8 C API Prepared Statements
20.6.9 C API Prepared Statement Data Structures
20.6.10 C API Prepared Statement Function Overview
20.6.11 C API Prepared Statement Function Descriptions
20.6.12 C API Threaded Function Descriptions
20.6.13 C API Embedded Server Function Descriptions
20.6.14 Common Questions and Problems When Using the C API
20.6.15 Controlling Automatic Reconnection Behavior
20.6.16 C API Support for Multiple Statement Execution
20.6.17 C API Prepared Statement Problems
20.6.18 C API Prepared Statement Handling of Date and Time Values
20.6.19 C API Support for Prepared CALL Statements
20.8 MySQL Perl API
20.9 MySQL Python API
20.10 MySQL Ruby APIs
20.10.1 The MySQL/Ruby API
20.10.2 The Ruby/MySQL API
20.11 MySQL Tcl API
20.12 MySQL Eiffel Wrapper

MySQL Connectors provide connectivity to the MySQL server for client programs. APIs provide low-level access to the MySQL protocol and MySQL resources. Both Connectors and the APIs enable you to connect and execute MySQL statements from another language or environment, including ODBC, Java (JDBC), Perl, Python, PHP, Ruby, and native C and embedded MySQL instances.


Connector version numbers do not correlate with MySQL Server version numbers. See Table 20.2, “MySQL Connector Versions and MySQL Server Versions”.

MySQL Connectors

Oracle develops a number of connectors:


For direct access to using MySQL natively within a C application, there are two methods:

See also Section 20.6.1, “MySQL C API Implementations”.

To access MySQL from a C application, or to build an interface to MySQL for a language not supported by the Connectors or APIs in this chapter, the C API is where to start. A number of programmer's utilities are available to help with the process; see Section 4.7, “MySQL Program Development Utilities”.

Third-Party MySQL APIs

The remaining APIs described in this chapter provide an interface to MySQL from specific application languages. These third-party solutions are not developed or supported by Oracle. Basic information on their usage and abilities is provided here for reference purposes only.

All the third-party language APIs are developed using one of two methods, using libmysqlclient or by implementing a native driver. The two solutions offer different benefits:

Table 20.1, “MySQL APIs and Interfaces” lists many of the libraries and interfaces available for MySQL. Table 20.2, “MySQL Connector Versions and MySQL Server Versions” shows which MySQL Server versions each connector supports.

Table 20.1 MySQL APIs and Interfaces

AdaGNU Ada MySQL BindingslibmysqlclientSee MySQL Bindings for GNU Ada
CC APIlibmysqlclientSee Section 20.6, “MySQL C API”.
CConnector/CReplacement for libmysqlclientSee MySQL Connector/C Developer Guide.
C++Connector/C++libmysqlclientSee MySQL Connector/C++ Developer Guide.
 MySQL++libmysqlclientSee MySQL++ Web site.
 MySQL wrappedlibmysqlclientSee MySQL wrapped.
CocoaMySQL-CocoalibmysqlclientCompatible with the Objective-C Cocoa environment. See
DMySQL for DlibmysqlclientSee MySQL for D.
EiffelEiffel MySQLlibmysqlclientSee Section 20.12, “MySQL Eiffel Wrapper”.
Erlangerlang-mysql-driverlibmysqlclientSee erlang-mysql-driver.
HaskellHaskell MySQL BindingsNative DriverSee Brian O'Sullivan's pure Haskell MySQL bindings.
 hsql-mysqllibmysqlclientSee MySQL driver for Haskell .
Java/JDBCConnector/JNative DriverSee MySQL Connector/J 5.1 Developer Guide.
KayaMyDBlibmysqlclientSee MyDB.
LuaLuaSQLlibmysqlclientSee LuaSQL.
.NET/MonoConnector/NetNative DriverSee MySQL Connector/Net Developer Guide.
Objective CamlOBjective Caml MySQL BindingslibmysqlclientSee MySQL Bindings for Objective Caml.
OctaveDatabase bindings for GNU OctavelibmysqlclientSee Database bindings for GNU Octave.
ODBCConnector/ODBClibmysqlclientSee MySQL Connector/ODBC Developer Guide.
PerlDBI/DBD::mysqllibmysqlclientSee Section 20.8, “MySQL Perl API”.
 Net::MySQLNative DriverSee Net::MySQL at CPAN
PHPmysql, ext/mysql interface (deprecated)libmysqlclientSee Original MySQL API.
 mysqli, ext/mysqli interfacelibmysqlclientSee MySQL Improved Extension.
 PDO_MYSQLlibmysqlclientSee MySQL Functions (PDO_MYSQL).
 PDO mysqlndNative Driver 
PythonConnector/PythonNative DriverSee MySQL Connector/Python Developer Guide.
PythonConnector/Python C ExtensionlibmysqlclientSee MySQL Connector/Python Developer Guide.
 MySQLdblibmysqlclientSee Section 20.9, “MySQL Python API”.
RubyMySQL/RubylibmysqlclientUses libmysqlclient. See Section 20.10.1, “The MySQL/Ruby API”.
 Ruby/MySQLNative DriverSee Section 20.10.2, “The Ruby/MySQL API”.
SchemeMyscshlibmysqlclientSee Myscsh.
SPLsql_mysqllibmysqlclientSee sql_mysql for SPL.
TclMySQLtcllibmysqlclientSee Section 20.11, “MySQL Tcl API”.

Table 20.2 MySQL Connector Versions and MySQL Server Versions

ConnectorConnector versionMySQL Server version
Connector/C6.1.0 GA5.6, 5.5, 5.1, 5.0, 4.1
Connector/C++1.0.5 GA5.6, 5.5, 5.1
Connector/J5.1.85.6, 5.5, 5.1, 5.0, 4.1
Connector/Net6.55.6, 5.5, 5.1, 5.0
Connector/Net6.45.6, 5.5, 5.1, 5.0
Connector/Net6.35.6, 5.5, 5.1, 5.0
Connector/Net6.2 (No longer supported)5.6, 5.5, 5.1, 5.0
Connector/Net6.1 (No longer supported)5.6, 5.5, 5.1, 5.0
Connector/Net6.0 (No longer supported)5.6, 5.5, 5.1, 5.0
Connector/Net5.2 (No longer supported)5.6, 5.5, 5.1, 5.0
Connector/Net1.0 (No longer supported)5.0, 4.0
Connector/ODBC5.15.6, 5.5, 5.1, 5.0, 4.1.1+
Connector/ODBC3.51 (Unicode not supported)5.6, 5.5, 5.1, 5.0, 4.1
Connector/Python2.05.7, 5.6, 5.5
Connector/Python1.25.7, 5.6, 5.5