Connect
Prerequisites
Section titled “Prerequisites”- You have a running instance of STACKIT MongoDB Flex. If not, you can start with Create and manage instances for MongoDB Flex.
- You have a user with proper permissions for your MongoDB Flex instance. If not, you can create one with Create and manage users and credentials for MongoDB Flex.
Compose the connection URI (optional)
Section titled “Compose the connection URI (optional)”To compose the URI with your credentials, you need the username, the password, the instance ID and the region. The default region is eu01.
This is the composition template:
| Parameter | Description | Example |
|---|---|---|
| Username | The name of the user | zvwn577e |
| Password | Password of the user | S7ihJf9cbFdfzd7m |
| Instance ID | The ID of your instance | 9092270d-c65a-45db-82bb-f259f3941f22 |
| Region | The region identifier | eu01 |
| Database | The database name | books |
mongodb://<Username>:<password>@s-<Instance ID>-0.mongodb.<Region>.onstackit.cloud:27017/<Database>?authSource=<Database>&tls=true&authMechanism=SCRAM-SHA-256This is an example for a connection URI:
mongodb://zvwn577e:S7ihJf9cbFdfzd7m@s-9092270d-c65a-45db-82bb-f259f3941f22-0.mongodb.eu01.onstackit.cloud:27017/books?authSource=books&tls=true&authMechanism=SCRAM-SHA-256Connect to your MongoDB Flex instance
Section titled “Connect to your MongoDB Flex instance”MongoDB Compass is a GUI for your local development environment. You can either download it on the official MongoDB website or install it with the sources of your operating system.
After installing and opening MongoDB Compass, you can connect to your database:
-
Click on Add new connection.
-
Paste the connection URI into the URI field.
-
You can optionally enter a custom friendly name in the Name field.
-
Click on Save & Connect.
MongoDB mongosh is a CLI tool to access the database. You can either download it on the official MongoDB website or install it with the sources of your operating system.
After installing and opening a shell of your choice, you can connect to your database:
mongosh 'mongodb://<USERNAME>:<YOUR-SECRET-PASSWORD>@s-<INSTANCE ID>-0.mongodb.<REGION>.onstackit.cloud:27017/default?authSource=default&tls=true&authMechanism=SCRAM-SHA-256'If you have problems connecting to your instance, consult the Troubleshooting article.