Dolt is a SQL database that you can fork, clone, branch, merge, push and pull just like a Git repository.
Connect to Dolt just like any MySQL database to read or modify schema and data. Version control functionality is exposed in SQL via system tables, functions, and procedures.
Or, use the Git-like command line interface to import CSV files, commit your changes, push them to a remote, or merge your teammate's changes. All the commands you know for Git work exactly the same for Dolt.
Git versions files. Dolt versions tables. It's like Git and MySQL had a baby.
We also built DoltHub, a place to share Dolt databases. We host public data for free. If you want to host your own version of DoltHub, we have DoltLab. If you want us to run a Dolt server for you, we have Hosted Dolt.
Prefer Postgres instead of MySQL? Try Doltgres, now in its Beta release.
Join us on Discord to say hi and ask questions, or check out our roadmap to see what we're building next.
Lots of things! Dolt is a generally useful tool with countless applications. But if you want some ideas, here's how people are using it so far.
Dolt powers Beads and Gas Town. It's the best database for agent memory, especially as you move up the ladder to multi-agent and multi-machine workflows.
The dolt CLI has the same commands as git, with some extras.
$ dolt
Valid commands for dolt are
init - Create an empty Dolt data repository.
status - Show the working tree status.
add - Add table changes to the list of staged table changes.
diff - Diff a table.
reset - Remove table changes from the list of staged table changes.
clean - Remove untracked tables from working set.
commit - Record changes to the repository.
sql - Run a SQL query against tables in repository.
sql-server - Start a MySQL-compatible server.
log - Show commit logs.
branch - Create, list, edit, delete branches.
checkout - Checkout a branch or overwrite a table from HEAD.
merge - Merge a branch.
conflicts - Commands for viewing and resolving merge conflicts.
cherry-pick - Apply the changes introduced by an existing commit.
revert - Undo the changes introduced in a commit.
clone - Clone from a remote data repository.
fetch - Update the database from a remote data repository.
pull - Fetch from a dolt remote data repository and merge.
push - Push to a dolt remote.
config - Dolt configuration.
remote - Manage set of tracked repositories.
backup - Manage a set of server backups.
login - Login to a dolt remote host.
creds - Commands for managing credentials.
ls - List tables in the working set.
schema - Commands for showing and importing table schemas.
table - Commands for copying, renaming, deleting, and exporting tables.
tag - Create, list, delete tags.
blame - Show what revision and author last modified each row of a table.
constraints - Commands for handling constraints.
migrate - Executes a database migration to use the latest Dolt data format.
read-tables - Fetch table(s) at a specific commit into a new dolt repo
gc - Cleans up unreferenced data from the repository.
filter-branch - Edits the commit history using the provided query.
merge-base - Find the common ancestor of two commits.
version - Displays the current Dolt cli version.
dump - Export all tables in the working set into a file.
Dolt is a single ~103 megabyte program.
dolt $ du -h /Users/timsehn/go/bin/dolt
103M /Users/timsehn/go/bin/dolt
It's really easy to install. Download it and put it on your PATH.
We have a bunch of ways to make this even easier for most platforms.
To install on Linux or Mac based systems run this command in your terminal:
sudo bash -c 'curl -L https://github.com/dolthub/dolt/releases/latest/download/install.sh | bash'
This will download the latest dolt release and put it in
/usr/local/bin/, which is probably on your $PATH.
The install script needs sudo in order to put dolt in /usr/local/bin. If you don't have root
privileges or aren't comfortable running a script with them, you can download the dolt binary
for your platform from the latest release, unzip it,
and put the binary somewhere on your $PATH.
Dolt is packaged in the official repositories for Arch Linux.
pacman -S dolt
Dolt is on Homebrew, updated every release.
brew install dolt
On macOS, Dolt can also be installed via a community-managed port via MacPorts:
sudo port install dolt
Download the latest Microsoft Installer (.msi file) in
releases and run
it.
For information on running on Windows, see here.
You can install dolt using Chocolatey:
choco install dolt
There are following official Docker images for Dolt:
dolthub/dolt for running Dolt
as CLI tool.dolthub/dolt-sql-server for running Dolt in server mode.Make sure you have Go installed, and that go is in your path. Dolt has a dependency on cgo, so you will need a working C compiler and toolchain as well.
Clone this repository and cd into the go directory. Then run:
go install ./cmd/dolt
The output will be in $GOPATH/bin, which defaults to ~/go/bin. To test your build, try:
~/go/bin/dolt version
Verify that your installation has succeeded by running dolt in your
terminal.
$ dolt
Valid commands for dolt are
[...]
Configure dolt with your user name and email, which you'll need to
create commits. The commands work exactly the same as git.
$ dolt config --global --add user.email YOU@DOMAIN.COM
$ dolt config --global --add user.name "YOUR NAME"
Dolt needs a place to store your databases. I'm going to put my databases in ~/dolt.
% cd ~
% mkdir dolt
% cd dolt
Any databases you create will be stored in this directory. So, for this example, a directory named getting_started will be created here once you run create database getting_started. Navigating to ~/dolt/getting_started will allow you to access this database using the Dolt command line.
NOTE: For this example, the getting_started directory will be created after you run create database getting_started; in a SQL shell in the Create a schema section. Don't do anything except make the directory and navigate to it just yet.
Dolt ships with a MySQL compatible database server built in. To start it you use the command dolt sql-server. Running this command starts the server on port 3306.
dolt sql-server
Starting server with Config HP="localhost:3306"|T="28800000"|R="false"|L="info"
Your terminal will just hang there. This means the server is running. Any errors will be printed in this terminal. Just leave it there and open a new terminal.
In the new terminal, we will now connect to the running database server using a client. Dolt also ships with a MySQL compatible client.
% dolt -u root -p "" sql
# Welcome to the Dolt MySQL client.
# Statements must be terminated with ';'.
# "exit" or "quit" (or Ctrl-D) to exit.
mysql>
In the other terminal where you ran dolt sql-server, you'll see the following log line.
2022-06-06T13:14:32-07:00 INFO [conn 1] NewConnection {DisableClientMultiStatements=false}
You are connected!
While we're here let's grab a copy of MySQL so we can connect with that client. Head over to the MySQL Getting Started documentation and install MySQL on your machine. I used Homebrew to install MySQL on my Mac: brew install mysql@8.4. Alternatively, you can install only the client component by running brew install mysql-client@8.4.
NOTE: Make sure you install a MySQL 8.4 release. MySQL 8.4 is the current Long Term Support (LTS) release, meaning this is the stable and supported version of MySQL. MySQL 9.0 is also available, but is an "innovation" release, meaning it has more recent changes and features, but may not be as stable as the LTS release. The 9.0 release changes authentication support and isn't able to connect to a Dolt SQL server by default. You can install MySQL 8.4 with Homebrew by running brew install mysql@8.4. If you do want to use MySQL-9.0, read our post on how to configure Dolt for caching_sha2_password authentication.
MySQL comes with a MySQL server called mysqld and a MySQL client called mysql. You're only interested in the client. After following the instructions from MySQL's documentation, make sure you have a copy of the mysql client on your path:
% mysql --version
mysql Ver 8.0.29 for macos12.2 on x86_64 (Homebrew)
Now, to connect the mysql client to Dolt, you are going to force the MySQL client through the TCP interface by passing in a host and port. The default is the socket interface which Dolt supports, but is only available on localhost. So, it's better to show off the TCP interface. The MySQL client also requires you specify a user, in this case root.
% mysql --host 127.0.0.1 --port 3306 -uroot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.9-Vitess
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
Again, to ensure the client actually connected, you should see the following in the dolt sql-server terminal
2022-06-06T13:26:55-07:00 INFO [conn 2] NewConnection {DisableClientMultiStatements=false}
As you can see, Dolt supports any MySQL-compatible client. Dolt ships with a client but you can use any MySQL client, like the one that comes with MySQL.
Now we're actually ready to do something interesting. I'll stay in the mysql client and execute the following SQL statements to create a database called getting_started. The getting_started database will have three tables: employees, teams, and employees_teams.
mysql> create database getting_started;
Query OK, 1 row affected (0.04 sec)
mysql> use getting_started;
Database changed
mysql> create table employees (
id int,
last_name varchar(255),
first_name varchar(255),
primary key(id));
Query OK, 0 rows affected (0.01 sec)
mysql> create table teams (
id int,
team_name varchar(255),
primary key(id));
Query OK, 0 rows affected (0.00 sec)
mysql> create table employees_teams(
team_id int,
employee_id int,
primary key(team_id, employee_id),
foreign key (team_id) references teams(id),
foreign key (employee_id) references employees(id));
Query OK, 0 rows affected (0.01 sec)
mysql> show tables;
+---------------------------+
| Tables_in_getting_started |
+---------------------------+
| employees |
| employees_teams |
| teams |
+---------------------------+
3 rows in set (0.00 sec)
Dolt supports foreign keys, secondary indexes, triggers, check constraints, and stored procedures. It's a modern, feature-rich SQL database.
It's time to use your first Dolt feature. We're going to make a Dolt commit. A Dolt commit allows you to time travel and see lineage. Make a Dolt commit whenever you want to restore or compare to this point in time.
Dolt exposes version control functionality through a Git-style interface. On the command line, Dolt commands map exactly to their Git equivalent with the targets being tables instead of files. In SQL, Dolt exposes version control read operations as system tables and version control write operations as stored procedures.
The naming of the system tables and stored procedures follows the dolt_<command> pattern. So dolt add on the CLI becomes dolt_add as a stored procedure. Passing options also fo