Setting Up
Introduction
Atlas CLI is an open-source tool designed to help software engineers, DBAs and DevOps practitioners to manage their database schemas. Atlas users can use the Atlas DDL (Data-definition language), to describe the desired database schema and use the command-line tool to plan and apply the migrations to their systems.
In this guide, we will install the latest version of Atlas, and use it to manage the schema of a local database that we will run inside a Docker container.
Install the CLI
- macOS (Homebrew)
- macOS (Plain)
- Linux
- Windows
Get the latest release with Homebrew:
brew install ariga/tap/atlas
Download latest release.
curl -LO https://release.ariga.io/atlas/atlas-darwin-amd64-latest
Make the atlas binary executable.
chmod +x ./atlas-darwin-amd64-latest
Move the atlas binary to a file location on your system PATH.
sudo mv ./atlas-darwin-amd64-latest /usr/local/bin/atlas
sudo chown root: /usr/local/bin/atlas
Download latest release.
curl -LO https://release.ariga.io/atlas/atlas-linux-amd64-latest
Move the atlas binary to a file location on your system PATH.
sudo install -o root -g root -m 0755 ./atlas-linux-amd64-latest /usr/local/bin/atlas
Download the latest release and move the atlas binary to a file location on your system PATH.
info
Latest release is updated twice a day and is based on the most recent tagged release.
The binaries distributed in official releases are released under the Ariga End User License. If you would like to build Atlas from source follow the instructions here.
To verify that the CLI is installed correctly run:
atlas
You should see the help text describing the different Atlas sub-commands:
A database toolkit.
Usage:
atlas [command]
Available Commands:
completion generate the autocompletion script for the specified shell
env Print atlas env params
help Help about any command
schema Work with atlas schemas
version Show atlas CLI version
Flags:
-h, --help help for atlas
Use "atlas [command] --help" for more information about a command.
Start a Local Database Container
For the purpose of this guide, we will start a local Docker container running MySQL.
docker run --name atlas-db -p 3306:3306 -e MYSQL_ROOT_PASSWORD=pass -e MYSQL_DATABASE=example mysql
To verify the local database is running, run the MySQL command-line interface from within the container:
docker exec -it atlas-db mysql --password='pass' example
Run show tables;
to verify that the database is empty:
mysql> show tables;
Empty set (0.00 sec)
mysql>
In the next section, we will learn how to use the Atlas CLI to inspect the schema of our running database.