# Setup Database

Bastion uses MongoDB to store its data. You can either install MongoDB on your own system or use a MongoDB cloud service like MongoDB Atlas.

{% tabs %}
{% tab title="Use MongoDB Atlas" %}
Head over to [mongodb.com/cloud/atlas](https://www.mongodb.com/cloud/atlas) and signup for a new account.

Create a database cluster by going to **Database > Create**.

<figure><img src="https://2090128309-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LKg6aQ3L4kyoODrZlxA%2Fuploads%2FnIg58SCXLCIIthern4QP%2Fimage.png?alt=media&#x26;token=1456b73a-b3f3-4b03-9fa9-bd501179f56a" alt=""><figcaption><p>MongoDB Atlas provides provides one free shared cluster that should be more than enough for Bastion.</p></figcaption></figure>

Add a database user by going to **Database Access > Add new database user**.

Use **Password** authentication method. The set the username and password you want. Ensure it is secure though.

Add a **Built-in Role** and select the **Read and write to any database** option and click **Add User** to create the database user.

<figure><img src="https://2090128309-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LKg6aQ3L4kyoODrZlxA%2Fuploads%2FsClRRgtFiKjjoMR6Ta1p%2Fimage.png?alt=media&#x26;token=efe452cd-46c8-4853-abdb-a08d6cb2371e" alt=""><figcaption></figcaption></figure>

Now head back to **Database** and click on **Connect > Connect your application**.

Copy the connection URI and replace the `<password>` in the URI to the password you set for the database user you created earlier.

The URI will look like the following. Make sure to replace `<password>` and `<dbname>`, `<username>` and `<cluster>` will be filled out for you.

```
mongodb+srv://<username>:<password>@<cluster>.mongodb.net/<dbnamne>?retryWrites=true&w=majority
```

{% endtab %}

{% tab title="Install MongoDB" %}
If you want to install MongoDB on your on system follow the installation guide for your operating system before proceeding with the installation.

{% embed url="<https://www.mongodb.com/docs/manual/administration/install-community/>" %}
{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://bastion.gitbook.io/docs/prerequisites/mongodb.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
