连接器和 API

数据库连接器为客户端提供了连接数据库服务端的方式,APIs 提供了使用 MySQL 协议和资源的底层接口。无论是连接器还是 API,都可以用来在不同的语言和环境内连接服务器并执行 sql 语句,包括 odbc、java(jdbc)、Perl、Python、PHP、Ruby 和 C。

TiDB 兼容 MySQL(5.6、5.7) 的所有连接器和 API,包括:

使用 MySQL 连接器连接 TiDB

Oracle 官方提供了以下 API,TiDB 可以兼容所有这些 API。

使用 MySQL C API 连接 TiDB

如果使用 C 语言程序直接连接 TiDB,可以直接链接 libmysqlclient 库,使用 MySQL 的 C API,这是最主要的一种 C 语言连接方式,被各种客户端和 API 广泛使用,包括 Connector/C。

使用 MySQL 第三方 API 连接 TiDB

第三方 API 非 Oracle 官方提供,下表列出了常用的第三方 API:

EnvironmentAPITypeNotes
AdaGNU Ada MySQL BindingslibmysqlclientSee MySQL Bindings for GNU Ada
CC APIlibmysqlclientSee MySQL C API.
C++Connector/C++libmysqlclientSee MySQL Connector/C++ Developer Guide.
MySQL++libmysqlclientSee MySQL++ Web site.
MySQL wrappedlibmysqlclientSee MySQL wrapped.
Gogo-sql-driverNative DriverSee Mysql Go API
CocoaMySQL-CocoalibmysqlclientCompatible with the Objective-C Cocoa environment. See http://mysql-cocoa.sourceforge.net/
DMySQL for DlibmysqlclientSee MySQL for D.
EiffelEiffel MySQLlibmysqlclientSee Section 27.14, “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.
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 27.10, “MySQL Perl API”.
Net::MySQLNative DriverSee Net::MySQL at CPAN
PHPmysql, ext/mysqlinterface (deprecated)libmysqlclientSee Original MySQL API.
mysqli, ext/mysqliinterfacelibmysqlclientSee 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 27.11, “MySQL Python API”.
RubyMySQL/RubylibmysqlclientUses libmysqlclient. See Section 27.12.1, “The MySQL/Ruby API”.
Ruby/MySQLNative DriverSee Section 27.12.2, “The Ruby/MySQL API”.
SchemeMyscshlibmysqlclientSee Myscsh.
SPLsql_mysqllibmysqlclientSee sql_mysql for SPL.
TclMySQLtcllibmysqlclientSee Section 27.13, “MySQL Tcl API”.

TiDB 支持的连接器版本

ConnectorConnector version
Connector/C6.1.0 GA
Connector/C++1.0.5 GA
Connector/J5.1.8
Connector/Net6.9.9 GA
Connector/Net6.8.8 GA
Connector/ODBC5.1
Connector/ODBC3.51 (Unicode not supported)
Connector/Python2.0
Connector/Python1.2