TiUP Playground
TiUP Playground is a tool for running a local TiDB cluster for testing and development. Playground automatically downloads and starts all TiDB components.
Installing TiUP
# macOS / Linux
curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh
source ~/.zshrc # or ~/.bashrc
Running Playground
Default (Latest Components)
tiup playground
This command starts: 1 TiDB, 1 TiKV, 1 PD, and 1 TiFlash (optional).
With a Specific Version and Node Count
# TiDB v8.5.7, 2 TiDB, 3 PD, 3 TiKV
tiup playground v8.5.7 --db 2 --pd 3 --kv 3
# Without TiFlash
tiup playground --db 1 --pd 1 --kv 1
Persisting Data with a Tag
By default, data is lost after the playground is stopped. To persist data:
tiup playground --tag my-data
Accessing Components
MySQL Client
mysql --host 127.0.0.1 --port 4000 -u root
TiDB Dashboard
Open your browser: http://127.0.0.1:2379/dashboard
- Username:
root - Password: (empty)
Grafana
Open your browser: http://127.0.0.1:3000
- Username:
admin - Password:
admin
Prometheus
Open your browser: http://127.0.0.1:9090
Example SQL Operations
-- Create the database
CREATE DATABASE IF NOT EXISTS mydb;
-- Use the database
USE mydb;
-- Create a table
CREATE TABLE users (
id INT PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(100) NOT NULL,
email VARCHAR(100) UNIQUE,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- Insert data
INSERT INTO users (name, email) VALUES
('John', '[email protected]'),
('Mike', '[email protected]');
-- Query data
SELECT * FROM users;
Cleaning Up the Cluster
# Stop the playground (Ctrl+C), then clean up
tiup clean --all
When to Use Playground?
| Scenario | Use Playground? |
|---|---|
| Trying TiDB for the first time | Yes |
| Testing SQL features | Yes |
| Testing a small application | Yes |
| Load testing | No (use tiup cluster) |
| Production deployment | No (use tiup cluster) |
In the next chapter, we will study TiUP Cluster for production deployments.