# Dolt — The SQL Database You Can Fork, Clone, Branch and Merge > The world's first version-controlled SQL database. Dolt combines MySQL compatibility with Git-style branching, diffing and merging so schemas and data can be reviewed and pull-requested. ## Install Save in your project root: # Dolt — The SQL Database You Can Fork, Clone, Branch and Merge ## Quick Use ```bash # Install curl -L https://github.com/dolthub/dolt/releases/latest/download/install.sh | sudo bash # Init, branch, commit mkdir shop && cd shop dolt init dolt sql -q "CREATE TABLE items (id INT PRIMARY KEY, name VARCHAR(64), price DECIMAL(10,2));" dolt sql -q "INSERT INTO items VALUES (1,'Mug',9.99);" dolt add . && dolt commit -m "seed catalogue" dolt checkout -b promo dolt sql -q "UPDATE items SET price = price * 0.8;" dolt diff main promo # row-level diff dolt merge promo # Git-style merge back into main ``` ## Introduction Dolt is an open-source SQL database that stores its tables, schemas and commit history in a Merkle DAG, so every operation you expect from Git — clone, branch, diff, merge, log, blame, push, pull — works on live data. It speaks the MySQL wire protocol, so existing drivers, ORMs and BI tools connect unchanged. ## What Dolt Does - Serves SQL over the MySQL protocol with a large subset of MySQL 8 syntax. - Versions both schema and rows: every `dolt commit` is content-addressed. - Produces row-level diffs between branches or commits with `dolt diff` or `dolt_diff_`. - Merges branches, detecting schema and data conflicts that you can resolve in SQL. - Pushes and pulls repositories to DoltHub or any S3-compatible remote. ## Architecture Overview Under the hood Dolt stores data in Prolly Trees — B-tree-like structures with content-addressed chunks that make cheap structural sharing possible across branches. A commit references a root hash covering every table, so diffing two commits is an O(changes) tree walk. The SQL layer is a query engine that reads and writes Prolly Trees transactionally and speaks the MySQL protocol. ## Self-Hosting & Configuration - Install the single Go binary; no external dependencies. - Run `dolt sql-server` to expose the MySQL protocol on port 3306 for BI tools and drivers. - Configure users and grants with standard `CREATE USER` / `GRANT` statements. - Back up by cloning the repo to S3/GCS using `dolt remote add` + `dolt push`. - Use `doltgres` when you need the PostgreSQL wire protocol instead. ## Key Features - Time-travel queries: `SELECT * FROM items AS OF 'HEAD~3';`. - Dolt functions: `dolt_commit()`, `dolt_merge()`, `dolt_branch()` callable from SQL. - `dolt_history_
` and `dolt_diff_
` system tables for auditing. - CI integration via `dolt ci` to test data changes the way you test code. - Free public hosting for open datasets on DoltHub. ## Comparison with Similar Tools - **Git LFS / DVC** — version files, not live SQL tables. - **TerminusDB** — graph-oriented, not MySQL-compatible. - **LakeFS** — Git semantics on object storage, but no SQL engine. - **Liquibase / Flyway** — version schema migrations only, not data. - **Postgres + temporal tables** — auditing but no branching or merging. ## FAQ **Q:** Is Dolt a drop-in replacement for MySQL? A: For most CRUD workloads, yes. Some replication and niche engine features are not implemented. **Q:** How big can a Dolt database get? A: Multi-hundred-GB repos are in production; performance scales with Prolly Tree chunking. **Q:** Can I branch terabytes without copying? A: Yes — branches share chunks, so they are metadata operations. **Q:** Is Dolt good for OLAP? A: It is tuned for OLTP-ish data with versioning. For heavy analytics, export to DuckDB or ClickHouse. ## Sources - https://github.com/dolthub/dolt - https://docs.dolthub.com/ --- Source: https://tokrepo.com/en/workflows/f8c7831d-391f-11f1-9bc6-00163e2b0d79 Author: AI Open Source