ScriptsApr 11, 2026·3 min read

TiDB — Distributed SQL Database with MySQL Compatibility

TiDB is an open-source, cloud-native, distributed SQL database that supports hybrid transactional and analytical processing (HTAP). MySQL-compatible wire protocol, horizontal scalability, strong consistency, and elastic scaling.

TL;DR
Open-source distributed SQL database with MySQL wire protocol, HTAP, horizontal scaling, and strong consistency.
§01

What it is

TiDB is an open-source, cloud-native, distributed SQL database that supports hybrid transactional and analytical processing (HTAP). It speaks the MySQL wire protocol, so existing MySQL applications can connect to TiDB with minimal code changes. Under the hood, TiDB separates compute and storage, enabling horizontal scalability, strong consistency, and elastic scaling without manual sharding.

Engineering teams running MySQL at scale who hit single-node limits benefit most from TiDB. It is designed for applications that need both OLTP (transactions) and OLAP (analytics) without maintaining separate databases.

§02

How it saves time or tokens

TiDB eliminates manual sharding, which is the biggest time sink in scaling MySQL. Instead of rewriting application code to route queries across shards, TiDB handles distribution transparently. The HTAP capability removes the need to maintain a separate analytics database and ETL pipeline, saving the engineering time of keeping two systems in sync.

§03

How to use

  1. Install TiUP (TiDB's package manager) and start a local playground
  2. Connect with any MySQL client using the standard MySQL protocol
  3. Scale out by adding TiKV storage nodes or TiDB compute nodes
§04

Example

# Install TiUP
curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh
source ~/.zshrc

# Start a local playground cluster
tiup playground

# Connect with standard MySQL client
mysql -h 127.0.0.1 -P 4000 -u root

# Use standard SQL
CREATE DATABASE myapp;
USE myapp;
CREATE TABLE users (id BIGINT PRIMARY KEY AUTO_RANDOM, name VARCHAR(255));
INSERT INTO users (name) VALUES ('Alice');
SELECT * FROM users;
§05

Related on TokRepo

§06

Common pitfalls

  • AUTO_INCREMENT behaves differently in distributed mode; use AUTO_RANDOM for primary keys to avoid hotspots
  • Some MySQL features (stored procedures, certain window functions) have limited support; check TiDB's compatibility matrix
  • A minimum production deployment requires 3 PD nodes, 3 TiKV nodes, and 2 TiDB nodes, which is significant infrastructure

Frequently Asked Questions

Is TiDB a drop-in replacement for MySQL?+

TiDB supports the MySQL wire protocol and most MySQL syntax. Many applications work without code changes. However, some MySQL-specific features like stored procedures, triggers, and certain functions differ. Test your application against TiDB before migrating.

How does TiDB achieve horizontal scaling?+

TiDB separates compute (TiDB nodes) from storage (TiKV nodes). You add TiKV nodes to increase storage capacity and TiDB nodes to handle more connections. Data is automatically rebalanced across nodes without downtime.

What is HTAP in TiDB?+

HTAP means hybrid transactional and analytical processing. TiDB handles both OLTP workloads (inserts, updates, point queries) and OLAP workloads (aggregations, joins, analytics) in one database using TiFlash, a columnar storage engine.

Is TiDB free?+

Yes. TiDB is open-source under the Apache 2.0 license. PingCAP (the company behind TiDB) offers a managed cloud service (TiDB Cloud) with paid tiers for teams that prefer not to manage infrastructure.

How does TiDB compare to CockroachDB?+

Both are distributed SQL databases. TiDB uses MySQL protocol compatibility; CockroachDB uses PostgreSQL compatibility. TiDB has stronger HTAP capabilities via TiFlash. CockroachDB emphasizes multi-region deployments. Choose based on your protocol preference and workload type.

Citations (3)

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets