DEV Community

Rutam Prita Mishra
Rutam Prita Mishra

Posted on

Database GitOps with Bytebase for MySQL


GitOps is a powerful methodology for managing infrastructure and application configurations using Git repositories. Bytebase is a database management tool that simplifies collaboration on database schemas, automates migrations, and enables GitOps workflows. This tutorial guides you through setting up Database GitOps with Bytebase for a MySQL database. By the end of this tutorial, you will have a MySQL database with its schema version controlled in a Git repository using Bytebase.


Before you start, ensure you have the following prerequisites:

  1. A running MySQL database server.
  2. Git installed on your local machine.
  3. Docker and Docker Compose (for running Bytebase).

Step 1: Install and Set Up Bytebase

Bytebase is available as a Docker container, making it easy to set up. Follow these steps to get it up and running:

  1. Create a directory for your Bytebase configuration and navigate to it in your terminal.

  2. Create a docker-compose.yaml file with the following content:

   version: '3'
       image: bytebase/bytebase
         - 8080:8080
         - DATABASE_URL=mysql://<username>:<password>@<db_host>:<db_port>/<db_name>
         - ./bytebase-data:/data
Enter fullscreen mode Exit fullscreen mode

Replace <username>, <password>, <db_host>, <db_port>, and <db_name> with your MySQL database details.

  1. Run the following command to start the Bytebase container:
   docker-compose up -d
Enter fullscreen mode Exit fullscreen mode
  1. Bytebase should now be accessible at http://localhost:8080. Open your web browser and access this URL to complete the initial setup of Bytebase.

Step 2: Create a Bytebase Project

  1. After setting up Bytebase, create a new project. A project acts as a container for all the database schemas and changes related to a specific application or service.

  2. Click on the newly created project to access its dashboard.

Step 3: Set Up a Git Repository

Now, set up a Git repository to store your database schema and migrations. You can use a Git hosting service such as GitHub, GitLab, or Bitbucket.

  1. Create a new Git repository for your project and initialize it with a README or an empty commit.

  2. Clone the repository to your local machine.

  3. In the Bytebase project dashboard, navigate to the "Settings" tab and select "Git Repository."

  4. Fill in the Git repository details, including the URL, branch name, username, and password or token if required.

  5. Save the Git repository configuration.

Step 4: Configure Database Connections

To manage your MySQL database using Bytebase, you need to configure a database connection.

  1. In the Bytebase project dashboard, go to the "Settings" tab and select "Database Connections."

  2. Click "Create Database Connection" and provide the necessary information, including the database type, connection name, host, port, database name, username, and password.

  3. Save the database connection.

Step 5: Create and Track Schema

With Bytebase and your Git repository set up, it's time to create and track your database schema:

  1. In the Bytebase project dashboard, navigate to the "Database" section and select your configured database connection.

  2. Click on "Schema" to create a new schema. You can create tables, indexes, and other database objects here.

  3. After creating your schema, navigate to the "Migrations" tab and create a migration for the schema changes.

  4. Once your migration is created, you can review and validate it.

  5. Commit and push your migration to the Git repository you set up earlier.

  6. Bytebase will automatically track your schema changes in the Git repository.

Step 6: Collaborate and Deploy Changes

Bytebase allows multiple team members to collaborate on database schema changes, review migrations, and deploy them.

  1. Invite team members to your Bytebase project by sharing the project's URL with them.

  2. Team members can access the project, review migrations, and approve them.

  3. Deploy approved migrations to your MySQL database using Bytebase.


In this tutorial, you've set up Database GitOps with Bytebase for a MySQL database. You've learned how to:

  1. Install and configure Bytebase using Docker.
  2. Create a Bytebase project and configure Git repository and database connections.
  3. Track and version-control your MySQL database schema and migrations using Git.
  4. Collaborate with team members and deploy changes to the database.

This approach streamlines your database management processes, making it easier to manage schema changes and collaborate with team members while keeping everything under version control.

Lastly, before you leave, don't forget to drop a Like and share it with your peers.


Top comments (0)