Skip to content

Connect a database from a self deployed MongoDB Community Edition

This guide will take you through all the neccessary steps needed to connect a database from a self deployed standalone MongoDB Community Edition instance to Florentine.ai:

Create a readonly user

Start by connecting to your database via MongoDB shell. You might have to modify the command, i.e. add your own host and/or a different port, see Connect to a Deployment in the MongoDB docs in case you need help:

mongosh --host localhost --port 27017

Switch to the database you want to connect to Florentine.ai. Replace <db_name> with your actual database name:

use <db_name>

Run the following command to create a read-only user. Replace <db_name> with your actual database name, <db_username> with a username (i.e. florentine) and <db_password> with a strong password. Make sure you copy the username and password because you need it for the connection string later:

db.createUser({
  user: "<db_username>",
  pwd: "<db_password>",
  roles: [{ role: "read", db: "<db_name>" }]
})

If you have not yet configured your MongoDB instance to use authorization: enabled you must add to your mongod.conf file:

security:
  authorization: enabled

Then restart your mongod process:

DANGER

Please note that all services connecting to the database without authentication will start failing. Make sure that you create an admin user before restarting and check that all other services use proper authentication before restarting.

Please see Use SCRAM to Authenticate Clients on Self-Managed Deployments in the MongoDB docs for more information.

sudo systemctl restart mongod

Grant network access

Besides a user with database access Florentine.ai needs network access as well. You need to add the Florentine.ai IP 167.99.246.57 and 209.38.238.253 to bindIp to your mongod.conf file:

net:
  bindIp: 127.0.0.1,167.99.246.57,209.38.238.253

Restart your mongod process:

sudo systemctl restart mongod

Please note

Depending on your setup you might as well need to configure your firewall settings to allow the Florentine.ai IP 167.99.246.57 and 209.38.238.253.

Create the connection string

You should now be able to create the connection string you need to add in your Floretine.ai account. The structure of the connection string looks like this:

mongodb://<db_username>:<db_password>@<domain>:<port>/<db_name>

Now you only need to replace <db_username>, <db_password>, <domain>, <port> and <db_name> with your settings, so your final connection string should look comparable to this:

mongodb://florentine:[email protected]:27017/samples

Enter your final connection string on the connect page in your Florentine.ai account, click on Connect and if everything is configured correct you should see a list of the collections inside your database.