Skip to main content

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

Get the latest release with Homebrew:

brew install ariga/tap/atlas
info

Latest release is updated twice a day and is based on the most recent tagged release.

The distributed binaries include code for a Management UI wrapping the core Atlas engine that is not currently released publicly. The binaries themselves are released under the Ariga End User License. If you would like to build Atlas from source without the UI 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.