> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bytebase.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Just-in-Time Database Access via GUI

In a production environment, an incident arises that requires a developer to access the production database for troubleshooting. However, the developer does not have the necessary access privileges. To address this, the developer can request Just-in-Time (JIT) access to the production database. Bytebase streamlines this process, allowing developers to efficiently request and obtain temporary access when needed.

This tutorial will guide you through setting up Just-in-Time (JIT) access using the Bytebase GUI. In the next tutorial, we will explore automating JIT access through Slack by leveraging Bytebase webhooks and API.

<img src="https://mintcdn.com/dbx/L1emqLVGwC-B6xvQ/content/docs/tutorials/just-in-time-database-access-part1/jit-graph1.webp?fit=max&auto=format&n=L1emqLVGwC-B6xvQ&q=85&s=c25cdb9a69ce750ec5ba7f5d3795c651" alt="jit-graph1" width="2415" height="1759" data-path="content/docs/tutorials/just-in-time-database-access-part1/jit-graph1.webp" />

***

This is Part 1 of our tutorial series on implementing Just-in-Time (JIT) database access:

* Part 1: JIT database access via GUI (this one)
* Part 2: [JIT database access via Slack](/tutorials/just-in-time-database-access-part2)

<Tip>
  If you use AWS Aurora/RDS, you can check out [Just-in-time Database Access to Amazon Aurora](/tutorials/just-in-time-database-access-amazon-aurora/) for AWS-specific setup.
</Tip>

## Prerequisites

Before you begin, make sure you have:

* [Docker](https://www.docker.com/) installed

## Step 1 - Run Bytebase in Docker and register a developer user

1. Make sure your docker daemon is running, and start the Bytebase docker container by typing the following command in the terminal.

   ```bash theme={null}
   docker run --rm --init \
     --name bytebase \
     --publish 8080:8080 --pull always \
     --volume ~/.bytebase/data:/var/opt/bytebase \
     bytebase/bytebase:latest
   ```

2. Open your browser and navigate to [http://localhost:8080](http://localhost:8080), you should see the Bytebase Signup page. The first registration user will be granted as the `Workspace Admin`.

3. Go into Bytebase console, click **IAM & Admin > Users & Groups** on the left sidebar, add a new dev user, giving it a `Project Developer` role which will apply to all projects.

## Step 2 - No access to production database

As a developer user, you will not have the access to query the production database by default.

1. Login as the developer user you created in Step 1, click **Select Project** on the top sidebar, choose `Sample Project`.

2. Click **Database** > **Databases** on the left bar, you should see two databases listed: `hr_prod` and `hr_test`.

3. Click `hr_prod`, you will see the SQL Editor icon is greyed out, which means you don't have access to this database in SQL Editor. Even you click **SQL Editor** button on the top bar to navigate to the SQL Editor page, you still don't have access to this database.

   <img src="https://mintcdn.com/dbx/L1emqLVGwC-B6xvQ/content/docs/tutorials/just-in-time-database-access-part1/bb-sql-editor-grey.webp?fit=max&auto=format&n=L1emqLVGwC-B6xvQ&q=85&s=860bcb691bd2e0e4ea8ea8809517f4e3" alt="bb-sql-editor-grey" width="2464" height="1024" data-path="content/docs/tutorials/just-in-time-database-access-part1/bb-sql-editor-grey.webp" />

## Step 3 - DBA assign you access to the production database (Community and Pro Plan)

In Bytebase **Community** and **Pro Plan**, the Admin/DBA can assign you access to the production database.

1. Login as the Admin user, go into `Sample Project`, click **Manage** > **Members** on the left sidebar.

2. Find the developer user you created in Step 1, click **Edit** pen button and then click **Grant Access** button.

3. In the **Grant Access** modal, select the `SQL Editor User` role, then set 1 day Expiration, and click **Confirm** button. Here you may notice in Community and Pro Plan, you can only set access to all databases in the project.

   <img src="https://mintcdn.com/dbx/L1emqLVGwC-B6xvQ/content/docs/tutorials/just-in-time-database-access-part1/bb-community-grant-query.webp?fit=max&auto=format&n=L1emqLVGwC-B6xvQ&q=85&s=7db7cd7531dbda1847b0a00a4d48a37a" alt="bb-community-grant-query" width="2524" height="1220" data-path="content/docs/tutorials/just-in-time-database-access-part1/bb-community-grant-query.webp" />

4. After the access is granted, login as the developer user again, you should see the SQL Editor icon is no longer greyed out, which means you have access to the production database in SQL Editor. After one day, the access will expire automatically.

   <img src="https://mintcdn.com/dbx/L1emqLVGwC-B6xvQ/content/docs/tutorials/just-in-time-database-access-part1/bb-sql-editor-query.webp?fit=max&auto=format&n=L1emqLVGwC-B6xvQ&q=85&s=9bf6b2870958063e5f8a2e392392d8d9" alt="bb-sql-editor-query" width="2554" height="1160" data-path="content/docs/tutorials/just-in-time-database-access-part1/bb-sql-editor-query.webp" />

## Step 4 - Request a JIT access to the production database (Enterprise Plan)

In Bytebase **Enterprise Plan**, you can request a JIT access to the production database.

1. Login as Admin user, go into `Sample Project` and revoke the developer user's access to the production database.

2. Upgrade to the **Enterprise Plan**. You may request a 14-day trial from [here](https://www.bytebase.com/contact-us/).

3. Click **CI/CD** > **Custom Approval** on the left sidebar. Assign licenses to the instances to enable this feature.

   <img src="https://mintcdn.com/dbx/L1emqLVGwC-B6xvQ/content/docs/tutorials/just-in-time-database-access-part1/bb-assign-license.webp?fit=max&auto=format&n=L1emqLVGwC-B6xvQ&q=85&s=098f9353383b0a14e39e49f1f7761f9f" alt="bb-assign-license" width="2864" height="1462" data-path="content/docs/tutorials/just-in-time-database-access-part1/bb-assign-license.webp" />

4. Scroll down to **Request Querier Role** section, add `high` risk an approval flow `Project Owner`.

   <img src="https://mintcdn.com/dbx/L1emqLVGwC-B6xvQ/content/docs/tutorials/just-in-time-database-access-part1/bb-custom-approval.webp?fit=max&auto=format&n=L1emqLVGwC-B6xvQ&q=85&s=5b12aed8b53a8434e0500619d985b722" alt="bb-custom-approval" width="2422" height="1042" data-path="content/docs/tutorials/just-in-time-database-access-part1/bb-custom-approval.webp" />

5. Click **CI/CD** > **Risks** on the left sidebar. Define a High risk policy for `Request Querier Role` which triggers when the environment is `Prod`.

   <img src="https://mintcdn.com/dbx/L1emqLVGwC-B6xvQ/content/docs/tutorials/just-in-time-database-access-part1/bb-risk-center.webp?fit=max&auto=format&n=L1emqLVGwC-B6xvQ&q=85&s=b147a233ea8ca52c37f49ca5d073d517" alt="bb-risk-center" width="2034" height="1128" data-path="content/docs/tutorials/just-in-time-database-access-part1/bb-risk-center.webp" />

6. Login as the developer user again, then go to SQL Editor page. Click **Connect to a database** or **Select a database to start**. You should see the `hr_prod` and `hr_test` databases listed, click **Request query** to request a JIT access.

   <img src="https://mintcdn.com/dbx/L1emqLVGwC-B6xvQ/content/docs/tutorials/just-in-time-database-access-part1/bb-sql-editor-request.webp?fit=max&auto=format&n=L1emqLVGwC-B6xvQ&q=85&s=c183686a9b22999c74c4ea4b7b43bf4a" alt="bb-sql-editor-request" width="2346" height="932" data-path="content/docs/tutorials/just-in-time-database-access-part1/bb-sql-editor-request.webp" />

7. Another way is to go to **Database > Databases** page, click **Request Querier Role**.

   <img src="https://mintcdn.com/dbx/L1emqLVGwC-B6xvQ/content/docs/tutorials/just-in-time-database-access-part1/bb-databases-request.webp?fit=max&auto=format&n=L1emqLVGwC-B6xvQ&q=85&s=863a9c7592f3f7bb759abae0714f9d49" alt="bb-databases-request" width="2282" height="850" data-path="content/docs/tutorials/just-in-time-database-access-part1/bb-databases-request.webp" />

8. In the **Request Querier Role** modal, choose **Manually select**, then `employee` `salary` and `title` under `hr_prod` database, and click **OK** button. Here you may also specify the expiration time which can be a specific time, or relative time from now.

   <img src="https://mintcdn.com/dbx/L1emqLVGwC-B6xvQ/content/docs/tutorials/just-in-time-database-access-part1/bb-sql-editor-choose.webp?fit=max&auto=format&n=L1emqLVGwC-B6xvQ&q=85&s=422a5e611c46ae60bb9259a0030bd725" alt="bb-sql-editor-choose" width="2426" height="1054" data-path="content/docs/tutorials/just-in-time-database-access-part1/bb-sql-editor-choose.webp" />

   <img src="https://mintcdn.com/dbx/L1emqLVGwC-B6xvQ/content/docs/tutorials/just-in-time-database-access-part1/bb-sql-editor-custom-expr.webp?fit=max&auto=format&n=L1emqLVGwC-B6xvQ&q=85&s=edeaa4e6602dc3b0f7edd63213626cb8" alt="bb-sql-editor-custom-expr" width="2264" height="1044" data-path="content/docs/tutorials/just-in-time-database-access-part1/bb-sql-editor-custom-expr.webp" />

9. An request issue will be created, switch to the project owner (the admin user), go to **Issue** page, you should see the request issue. Click **Approve** button to approve the request.

   <img src="https://mintcdn.com/dbx/L1emqLVGwC-B6xvQ/content/docs/tutorials/just-in-time-database-access-part1/bb-request-waiting.webp?fit=max&auto=format&n=L1emqLVGwC-B6xvQ&q=85&s=7d13195b915f7cc848000584720973c0" alt="bb-request-waiting" width="2420" height="1048" data-path="content/docs/tutorials/just-in-time-database-access-part1/bb-request-waiting.webp" />

10. Switch back to the developer user, go to SQL Editor page, you should be able to query from these three tables. If you query from other tables, you will get errors and suggest to request a JIT access.

    <img src="https://mintcdn.com/dbx/L1emqLVGwC-B6xvQ/content/docs/tutorials/just-in-time-database-access-part1/bb-sql-editor-not-ok.webp?fit=max&auto=format&n=L1emqLVGwC-B6xvQ&q=85&s=648db8dfde582490bea8b2f99c292ded" alt="bb-sql-editor-not-ok" width="2306" height="1090" data-path="content/docs/tutorials/just-in-time-database-access-part1/bb-sql-editor-not-ok.webp" />

11. After the developer user get the access, he can solve the incident. The admin user can revoke the access directly from the **Manage** > **Members** page or wait for the access expiration.

## Conclusion

In this tutorial, we demonstrated how to set up Just-in-Time (JIT) access using the Bytebase GUI. In the next tutorial, we will explore automating JIT access via Slack, utilizing Bytebase webhooks and API. Stay tuned!
