Table of Contents
MySQL Connectors provide connectivity to the MySQL server for client programs. APIs provide low-level access to MySQL resources using either the classic MySQL protocol or X Protocol. Both Connectors and the APIs enable you to connect and execute MySQL statements from another language or environment, including ODBC, Java (JDBC), C++, Python, Node.js, PHP, Perl, Ruby, and C.
Oracle develops a number of connectors:
Connector/C++ enables C++ applications to connect to MySQL.
Connector/J provides driver support for connecting to MySQL from Java applications using the standard Java Database Connectivity (JDBC) API.
Connector/NET enables developers to create .NET applications that connect to MySQL. Connector/NET implements a fully functional ADO.NET interface and provides support for use with ADO.NET aware tools. Applications that use Connector/NET can be written in any supported .NET language.
MySQL for Visual Studio works with Connector/NET and Microsoft Visual Studio 2012, 2013, 2015, and 2017. MySQL for Visual Studio provides access to MySQL objects and data from Visual Studio. As a Visual Studio package, it integrates directly into Server Explorer providing the ability to create new connections and work with MySQL database objects.
Connector/ODBC provides driver support for connecting to MySQL using the Open Database Connectivity (ODBC) API. Support is available for ODBC connectivity from Windows, Unix, and macOS platforms.
Connector/Python provides driver support for connecting to MySQL from Python applications using an API that is compliant with the Python DB API version 2.0. No additional Python modules or MySQL client libraries are required.
Connector/Node.js provides an asynchronous
API for connecting to MySQL from Node.js applications using
X Protocol. Connector/Node.js supports managing database
sessions and schemas, working with MySQL Document Store
collections and using raw SQL statements.
For direct access to using MySQL natively within a C application,
the C API provides low-level access to
the MySQL client/server protocol through the
libmysqlclient client library. This is the
primary method used to connect to an instance of the MySQL server,
and is used both by MySQL command-line clients and many of the MySQL
Connectors and third-party APIs detailed here.
libmysqlclient is included in MySQL distributions
See also 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, “Program Development Utilities”.
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
libmysqlclient or by implementing
a native driver. The two
solutions offer different benefits:
offers complete compatibility with MySQL because it uses the
same libraries as the MySQL client applications. However, the
feature set is limited to the implementation and interfaces
libmysqlclient and the
performance may be lower as data is copied between the native
language, and the MySQL API components.
Native drivers are an implementation of the MySQL network protocol entirely within the host language or environment. Native drivers are fast, as there is less copying of data between components, and they can offer advanced functionality not available through the standard MySQL API. Native drivers are also easier for end users to build and deploy because no copy of the MySQL client libraries is needed to build the native driver components.
Table 28.1, “MySQL APIs and Interfaces” lists many of the libraries and interfaces available for MySQL.
Table 28.1 MySQL APIs and Interfaces
|Ada||GNU Ada MySQL Bindings||
||See MySQL Bindings for GNU Ada|
||See MySQL 8.0 C API Developer Guide.|
||See MySQL Connector/C++ 8.0 Developer Guide.|
||See MySQL++ website.|
||See MySQL wrapped.|
||Compatible with the Objective-C Cocoa environment. See http://mysql-cocoa.sourceforge.net/|
|D||MySQL for D||
||See MySQL for D.|
||See Section 28.13, “MySQL Eiffel Wrapper”.|
|Haskell||Haskell MySQL Bindings||Native Driver||See Brian O'Sullivan's pure Haskell MySQL bindings.|
||See MySQL driver for Haskell.|
|Java/JDBC||Connector/J||Native Driver||See MySQL Connector/J 5.1 Developer Guide.|
|.NET/Mono||Connector/NET||Native Driver||See MySQL Connector/NET Developer Guide.|
|Objective Caml||OBjective Caml MySQL Bindings||
||See MySQL Bindings for Objective Caml.|
|Octave||Database bindings for GNU Octave||
||See Database bindings for GNU Octave.|
||See MySQL Connector/ODBC Developer Guide.|
||See Section 28.9, “MySQL Perl API”.|
||See Original MySQL API.|
||See MySQL Improved Extension.|
||See MySQL Functions (PDO_MYSQL).|
|PDO mysqlnd||Native Driver|
|Python||Connector/Python||Native Driver||See MySQL Connector/Python Developer Guide.|
|Python||Connector/Python C Extension||
||See MySQL Connector/Python Developer Guide.|
||See Section 28.10, “MySQL Python API”.|
|Ruby/MySQL||Native Driver||See Section 28.11.2, “The Ruby/MySQL API”.|
||See Section 28.12, “MySQL Tcl API”.|
The MySQL Connector/C++ manual is published in standalone form, not as part of the MySQL Reference Manual. For information, see these documents:
The MySQL Connector/J manual is published in standalone form, not as part of the MySQL Reference Manual. For information, see these documents:
The MySQL Connector/NET manual is published in standalone form, not as part of the MySQL Reference Manual. For information, see these documents:
The MySQL Connector/ODBC manual is published in standalone form, not as part of the MySQL Reference Manual. For information, see these documents:
The MySQL Connector/Python manual is published in standalone form, not as part of the MySQL Reference Manual. For information, see these documents:
The MySQL Connector/Node.js manual is published in standalone form, not as part of the MySQL Reference Manual. For information, see these documents:
Release notes: MySQL Connector/Node.js Release Notes
The MySQL C API Developer Guide is published in standalone form, not as part of the MySQL Reference Manual. See MySQL 8.0 C API Developer Guide.
The MySQL PHP API manual is now published in standalone form, not as part of the MySQL Reference Manual. See MySQL and PHP.
DBI module provides a generic interface
for database access. You can write a DBI script that works with many
different database engines without change. To use DBI with MySQL,
install the following:
DBD::mysql module. This is the DataBase
Driver (DBD) module for Perl.
Optionally, the DBD module for any other type of database server you want to access.
Perl DBI is the recommended Perl interface. It replaces an older
mysqlperl, which should be
These sections contain information about using Perl with MySQL and writing MySQL applications in Perl:
For installation instructions for Perl DBI support, see Section 2.13, “Perl Installation Notes”.
For an example of reading options from option files, see Section 5.8.4, “Using Client Programs in a Multiple-Server Environment”.
For secure coding tips, see Section 6.1.1, “Security Guidelines”.
For debugging tips, see Section 188.8.131.52, “Debugging mysqld under gdb”.
For some Perl-specific environment variables, see Section 4.9, “Environment Variables”.
For considerations for running on macOS, see Section 2.4, “Installing MySQL on macOS”.
For ways to quote string literals, see Section 9.1.1, “String Literals”.
DBI information is available at the command line, online, or in printed form:
Once you have the
DBD::mysql modules installed, you can get
information about them at the command line with the
You can also use
pod2html, and so on to translate this
information into other formats.
For online information about Perl DBI, visit the DBI website, http://dbi.perl.org/. That site hosts a general DBI mailing list.
For printed information, the official DBI book is Programming the Perl DBI (Alligator Descartes and Tim Bunce, O'Reilly & Associates, 2000). Information about the book is available at the DBI website, http://dbi.perl.org/.
MySQLdb is a third-party driver that provides
MySQL support for Python, compliant with the Python DB API version
2.0. It can be found at
The new MySQL Connector/Python component provides an interface to the same Python API, and is built into the MySQL Server and supported by Oracle. See MySQL Connector/Python Developer Guide for details on the Connector, as well as coding guidelines for Python applications and sample Python code.
Two APIs are available for Ruby programmers developing MySQL applications:
The MySQL/Ruby API is based on the
libmysqlclient API library. For information
on installing and using the MySQL/Ruby API, see
Section 28.11.1, “The MySQL/Ruby API”.
The Ruby/MySQL API is written to use the native MySQL network protocol (a native driver). For information on installing and using the Ruby/MySQL API, see Section 28.11.2, “The Ruby/MySQL API”.
For background and syntax information about the Ruby language, see Ruby Programming Language.
The MySQL/Ruby module provides access to MySQL databases using
For information on installing the module, and the functions exposed, see MySQL/Ruby.
The Ruby/MySQL module provides access to MySQL databases using Ruby through a native driver interface using the MySQL network protocol.
For information on installing the module, and the functions exposed, see Ruby/MySQL.
Eiffel MySQL is an interface to the MySQL database server using the Eiffel programming language, written by Michael Ravits. It can be found at http://efsa.sourceforge.net/archive/ravits/mysql.htm.