Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/pingcap/tidb/llms.txt

Use this file to discover all available pages before exploring further.

TiDB is MySQL-compatible and listens on port 4000. Once your cluster is running, you connect with any MySQL client and use standard SQL.
TiUP is PingCAP’s component manager. The playground command starts a single-node TiDB cluster on your laptop — no infrastructure required.
1

Install TiUP

Run the TiUP installer script:
curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh
After installation, reload your shell profile so the tiup command is available:
source ~/.bashrc
# or, on macOS with zsh:
source ~/.zshrc
2

Start a local cluster

Launch a playground cluster with one TiDB node, one TiKV node, and one PD node:
tiup playground
TiUP downloads the required components on first run. When the cluster is ready you will see output similar to:
To connect TiDB: mysql --comments --host 127.0.0.1 --port 4000 -u root
To start a cluster with TiFlash for HTAP queries, add the --tiflash 1 flag: tiup playground --tiflash 1
3

Connect with a MySQL client

Open a new terminal and connect using the MySQL CLI:
mysql -h 127.0.0.1 -P 4000 -u root
The root user has no password by default in the playground environment.

Create your first database and table

Once connected, run these SQL statements to create a sample schema and insert data. The example uses AUTO_INCREMENT for the primary key, which TiDB supports natively.
-- Create a database
CREATE DATABASE myapp;
USE myapp;

-- Create a table with an AUTO_INCREMENT primary key
CREATE TABLE users (
  id     BIGINT       NOT NULL AUTO_INCREMENT,
  name   VARCHAR(255) NOT NULL,
  email  VARCHAR(255) NOT NULL UNIQUE,
  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (id)
);

-- Insert rows
INSERT INTO users (name, email) VALUES
  ('Alice', 'alice@example.com'),
  ('Bob',   'bob@example.com');

-- Query
SELECT id, name, email, created_at FROM users;
Expected output:
+----+-------+-------------------+---------------------+
| id | name  | email             | created_at          |
+----+-------+-------------------+---------------------+
|  1 | Alice | alice@example.com | 2026-04-05 00:00:00 |
|  2 | Bob   | bob@example.com   | 2026-04-05 00:00:00 |
+----+-------+-------------------+---------------------+

Verify the HTTP status endpoint

TiDB exposes an HTTP API on port 10080 for metrics and status checks:
curl http://127.0.0.1:10080/status
The response includes the TiDB version and the Git hash of the build:
{
  "connections": 1,
  "version": "...",
  "git_hash": "..."
}

Configuration

TiDB reads a TOML configuration file. The most common settings are:
# TiDB server host
host = "0.0.0.0"

# MySQL protocol port (default 4000)
port = 4000

# HTTP status port (default 10080)
[status]
status-port = 10080

# Log level: debug, info, warn, error, fatal
[log]
level = "info"
Pass the config file to tidb-server with the --config flag:
tidb-server --config /etc/tidb/tidb.toml

Next steps

Architecture

Understand how TiDB Server, TiKV, TiFlash, and PD form a distributed cluster.

Introduction

Read the full feature overview and learn which use cases TiDB is designed for.

Build docs developers (and LLMs) love