- Introduction
- Concepts
- Architecture
- Key Features
- Horizontal Scalability
- MySQL Compatible Syntax
- Replicate from and to MySQL
- Distributed Transactions with Strong Consistency
- Cloud Native Architecture
- Minimize ETL with HTAP
- Fault Tolerance & Recovery with Raft
- Automatic Rebalancing
- Deployment and Orchestration with Ansible, Kubernetes, Docker
- JSON Support
- Spark Integration
- Read Historical Data Without Restoring from Backup
- Fast Import and Restore of Data
- Hybrid of Column and Row Storage
- SQL Plan Management
- Open Source
- Online Schema Changes
- How-to
- Get Started
- Deploy
- Hardware Recommendations
- From Binary Tarball
- Orchestrated Deployment
- Geographic Redundancy
- Data Migration with Ansible
- Configure
- Secure
- Transport Layer Security (TLS)
- Generate Self-signed Certificates
- Monitor
- Migrate
- Maintain
- Common Ansible Operations
- Backup and Restore
- Identify Abnormal Queries
- Scale
- Upgrade
- Troubleshoot
- Reference
- SQL
- MySQL Compatibility
- SQL Language Structure
- Data Types
- Functions and Operators
- Function and Operator Reference
- Type Conversion in Expression Evaluation
- Operators
- Control Flow Functions
- String Functions
- Numeric Functions and Operators
- Date and Time Functions
- Bit Functions and Operators
- Cast Functions and Operators
- Encryption and Compression Functions
- Information Functions
- JSON Functions
- Aggregate (GROUP BY) Functions
- Window Functions
- Miscellaneous Functions
- Precision Math
- List of Expressions for Pushdown
- SQL Statements
ADD COLUMN
ADD INDEX
ADMIN
ADMIN CANCEL DDL
ADMIN CHECKSUM TABLE
ADMIN CHECK [TABLE|INDEX]
ADMIN SHOW DDL [JOBS|QUERIES]
ALTER DATABASE
ALTER TABLE
ALTER USER
ANALYZE TABLE
BEGIN
CHANGE COLUMN
COMMIT
CREATE DATABASE
CREATE INDEX
CREATE ROLE
CREATE TABLE LIKE
CREATE TABLE
CREATE USER
CREATE VIEW
DEALLOCATE
DELETE
DESC
DESCRIBE
DO
DROP COLUMN
DROP DATABASE
DROP INDEX
DROP ROLE
DROP TABLE
DROP USER
DROP VIEW
EXECUTE
EXPLAIN ANALYZE
EXPLAIN
FLUSH PRIVILEGES
FLUSH STATUS
FLUSH TABLES
GRANT <privileges>
GRANT <role>
INSERT
KILL [TIDB]
LOAD DATA
LOAD STATS
MODIFY COLUMN
PREPARE
RECOVER TABLE
RENAME INDEX
RENAME TABLE
REPLACE
REVOKE <privileges>
REVOKE <role>
ROLLBACK
SELECT
SET DEFAULT ROLE
SET [NAMES|CHARACTER SET]
SET PASSWORD
SET ROLE
SET TRANSACTION
SET [GLOBAL|SESSION] <variable>
SHOW ANALYZE STATUS
SHOW CHARACTER SET
SHOW COLLATION
SHOW [FULL] COLUMNS FROM
SHOW CREATE TABLE
SHOW CREATE USER
SHOW DATABASES
SHOW ENGINES
SHOW ERRORS
SHOW [FULL] FIELDS FROM
SHOW GRANTS
SHOW INDEXES [FROM|IN]
SHOW INDEX [FROM|IN]
SHOW KEYS [FROM|IN]
SHOW PRIVILEGES
SHOW [FULL] PROCESSSLIST
SHOW SCHEMAS
SHOW STATUS
SHOW [FULL] TABLES
SHOW TABLE REGIONS
SHOW TABLE STATUS
SHOW [GLOBAL|SESSION] VARIABLES
SHOW WARNINGS
SPLIT REGION
START TRANSACTION
TRACE
TRUNCATE
UPDATE
USE
- Constraints
- Generated Columns
- Partitioning
- Character Set
- SQL Mode
- Views
- Configuration
- Security
- Transactions
- System Databases
- Errors Codes
- Supported Client Drivers
- Garbage Collection (GC)
- Performance
- Overview
- Understanding the Query Execution Plan
- The Blocklist of Optimization Rules and Expression Pushdown
- Introduction to Statistics
- TopN and Limit Push Down
- Optimizer Hints
- Check the TiDB Cluster Status Using SQL Statements
- Execution Plan Binding
- Statement Summary Table
- Tune TiKV
- Operating System Tuning
- Column Pruning
- Key Monitoring Metrics
- Alert Rules
- Best Practices
- TiSpark
- TiKV
- TiDB Binlog
- Tools
- TiDB in Kubernetes
- FAQs
- Support
- Contribute
- Releases
- All Releases
- v3.0
- v2.1
- v2.0
- v1.0
- Glossary
You are viewing the documentation of an older version of the TiDB database (TiDB v3.0).
Connectors and APIs
Database Connectors provide connectivity to the TiDB 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 C.
TiDB is compatible with all Connectors and APIs of MySQL (5.6, 5.7), including:
- MySQL Connector/C++
- MySQL Connector/J
- MySQL Connector/Net
- MySQL Connector/ODBC
- MySQL Connector/Python
- MySQL C API
- MySQL PHP API
- MySQL Perl API
- MySQL Python API
- MySQL Ruby APIs
- MySQL Tcl API
- MySQL Eiffel Wrapper
- Mysql Go API
Connect to TiDB using MySQL Connectors
Oracle develops the following APIs and TiDB is compatible with all of them:
- To connect to TiDB using a MySQL Connector from MySQL 8.0, you must explicitly specify
default-auth=mysql_native_password
, becausemysql_native_password
is no longer the default plugin.
- MySQL Connector/C++:to enable C++ applications to connect to MySQL
- MySQL Connector/J:to enable Java applications to connect to MySQL using the standard JDBC API
- MySQL Connector/Net:to enable .Net applications to connect to MySQL; MySQL for Visual Studio uses this; support Microsoft Visual Studio 2012, 2013, 2015 and 2017 versions
- MySQL Connector/ODBC:the standard ODBC API; support Windows, Unix, and OS X platforms
- MySQL Connector/Python:to enable Python applications to connect to MySQL, compliant with the Python DB API version 2.0
Connect to TiDB using MySQL C API
If you use C language programs to connect to TiDB, you can connect to libmysqlclient
directly and use the MySQL C API. This is one of the major connection methods using C language, widely used by various clients and APIs, including Connector/C.
Connect to TiDB using third-party MySQL APIs
The third-party APIs are not developed by Oracle. The following table lists the commonly used third-party APIs:
Environment | API | Type | Notes |
---|---|---|---|
Ada | GNU Ada MySQL Bindings | libmysqlclient | See MySQL Bindings for GNU Ada |
C | C API | libmysqlclient | See MySQL C API |
C++ | Connector/C++ | libmysqlclient | See MySQL Connector/C++ Developer Guide |
MySQL++ | libmysqlclient | See MySQL++ Web site | |
MySQL wrapped | libmysqlclient | See MySQL wrapped | |
Go | go-sql-driver | Native Driver | See Mysql Go API |
Cocoa | MySQL-Cocoa | libmysqlclient | Compatible with the Objective-C Cocoa environment. See http://mysql-cocoa.sourceforge.net/ |
D | MySQL for D | libmysqlclient | See MySQL for D |
Eiffel | Eiffel MySQL | libmysqlclient | See Section 27.14, “MySQL Eiffel Wrapper” |
Erlang | erlang-mysql-driver | libmysqlclient | See erlang-mysql-driver |
Haskell | Haskell MySQL Bindings | Native Driver | See Brian O'Sullivan's pure Haskell MySQL bindings |
hsql-mysql | libmysqlclient | See MySQL driver for Haskell | |
Java/JDBC | Connector/J | Native Driver | See MySQL Connector/J 5.1 Developer Guide |
Lua | LuaSQL | libmysqlclient | See LuaSQL |
.NET/Mono | Connector/Net | Native Driver | See MySQL Connector/Net Developer Guide |
Objective Caml | OBjective Caml MySQL Bindings | libmysqlclient | See MySQL Bindings for Objective Caml |
Octave | Database bindings for GNU Octave | libmysqlclient | See Database bindings for GNU Octave |
ODBC | Connector/ODBC | libmysqlclient | See MySQL Connector/ODBC Developer Guide |
Perl | DBI /DBD::mysql | libmysqlclient | See Section 27.10, “MySQL Perl API” |
Net::MySQL | Native Driver | See Net::MySQL at CPAN | |
PHP | mysql , ext/mysql interface (deprecated) | libmysqlclient | See Original MySQL API |
mysqli , ext/mysqli interface | libmysqlclient | See MySQL Improved Extension | |
PDO_MYSQL | libmysqlclient | 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 | libmysqlclient | See MySQL Connector/Python Developer Guide |
MySQLdb | libmysqlclient | See Section 27.11, “MySQL Python API” | |
Ruby | MySQL/Ruby | libmysqlclient | Uses libmysqlclient . See Section 27.12.1, “The MySQL/Ruby API” |
Ruby/MySQL | Native Driver | See Section 27.12.2, “The Ruby/MySQL API” | |
Scheme | Myscsh | libmysqlclient | See Myscsh |
SPL | sql_mysql | libmysqlclient | See sql_mysql for SPL |
Tcl | MySQLtcl | libmysqlclient | See Section 27.13, “MySQL Tcl API” |
Connector versions supported by TiDB
Connector | Connector Version |
---|---|
Connector/C | 6.1.0 GA |
Connector/C++ | 1.0.5 GA |
Connector/J | 5.1.8 |
Connector/Net | 6.9.9 GA |
Connector/Net | 6.8.8 GA |
Connector/ODBC | 5.1 |
Connector/ODBC | 3.51 (Unicode not supported) |
Connector/Python | 2.0 |
Connector/Python | 1.2 |