Skip to main content
Infisical supports the use of Username & Password authentication to connect with MongoDB databases.

Configure a MongoDB user for Infisical

1

Create a MongoDB user

Infisical recommends creating a designated user in your MongoDB database for your connection.
use [TARGET-DATABASE]
db.createUser({
  user: "infisical_manager",
  pwd: "[ENTER-YOUR-USER-PASSWORD]",
  roles: []
})
2

Grant Relevant Permissions

Depending on how you intend to use your MongoDB connection, you’ll need to grant one or more of the following permissions.
To learn more about MongoDB’s permission system, please visit their documentation.
  • Secret Rotation
For Secret Rotations, your Infisical user will require the ability to create, update, and delete users in the target database:
use [TARGET-DATABASE]
db.grantRolesToUser("infisical_manager", [
  { role: "userAdmin", db: "[TARGET-DATABASE]" }
])
The userAdmin role allows managing users (create, update passwords, delete) within the specified database.

Create MongoDB Connection in Infisical

  • Infisical UI
  • API
1

Navigate to App Connections

In your Infisical dashboard, navigate to the App Connections page in the desired project.App Connections Tab
2

Select MongoDB Connection

Click the + Add Connection button and select the MongoDB Connection option from the available integrations.Select MongoDB Connection
3

Fill out the MongoDB Connection Modal

Complete the MongoDB Connection form by entering:
  • A descriptive name for the connection
  • An optional description for future reference
  • The MongoDB host URL for your database
  • The MongoDB port for your database
  • The MongoDB username for your database
  • The MongoDB password for your database
  • The MongoDB database name to connect to
You can optionally configure SSL/TLS for your MongoDB connection in the SSL section.MongoDB Connection Modal
4

Connection Created

After clicking Create, your MongoDB Connection is established and ready to use with your Infisical project.MongoDB Connection Created