> For the complete documentation index, see [llms.txt](https://bastion.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://bastion.gitbook.io/docs/prerequisites/mongodb.md).

# 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&amp;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&amp;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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
