Learn how to connect to a MongoDB® database instance with one of the world's most famous Open Source (SSPL) management tools for MongoDB®: MongoDB Compass.
Cloud Databases allow you to focus on building and deploying cloud applications while OVHcloud takes care of the database infrastructure and maintenance in operational conditions.
Requirements
- A Public Cloud project in your OVHcloud account
- Access to the OVHcloud Control Panel
- A MongoDB® database running on your OVHcloud Cloud Databases (this guide can help you to meet this requirement)
- Configure your MongoDB® instance to accept incoming connections
- A MongoDB® Compass stable version installed and public network connectivity (Internet)
This guide was made in MongoDB® Compass version 1.30.1.
Concept
A MongoDB® instance can be managed in multiple ways. One of the easiest and most powerful is to use a Command Line Interface (CLI), as shown in our guide: Connect to MongoDB® with CLI or by using programming languages, such as PHP or Python.
Another way is to interact directly using a management tool for MongoDB®: MongoDB® Compass.
To do so, we will need to install MongoDB® Compass, configure our Cloud Databases for MongoDB® instances to accept incoming connections, and finally configure MongoDB®.
Instructions
Installation
Please follow the official documentation to install MongoDB® Compass.
We are now ready to learn how to connect to our MongoDB® instance.
Connect with MongoDB® Compass
In MongoDB® Compass, fill in the URI field with your service URI and click Connect:
Now you can interact with your Cloud Databases for MongoDB®:
Insert and Query Data
You can use the mongoshell, integrated into Compass, to create your first database and collection. Below is a script that creates the database company and collection customer and inserts 100 random documents.
Load Data into MongoDB®
To load 100 documents into a collection called customer with random data, use the following mongosh script:

Query Data with the Aggregation Framework
The MongoDB® aggregation pipeline below uses the MongoDB® Aggregation Framework to group customers by age and count each occurrence. You can use the mongoshell to execute:
You can also use the UI with Compass to execute the aggregation pipeline.

Go further
Visit the GitHub examples repository to find out how to connect to your database in several languages.
For more information and tutorials, please see our other Managed Databases & Analytics or Platform as a Service guides. You can also explore the guides for other OVHcloud products and services.
If you need training or technical assistance to implement our solutions, contact your sales representative or click on this link to get a quote and ask our Professional Services experts for a custom analysis of your project.
OVHcloud Managed Databases and Analytics:
- Grafana® is a registered trademark of Grafana Labs and is used with the permission of Grafana Labs. OVH SAS and its subsidiaries are not affiliated with or endorsed by Grafana Labs.
- Kafka® is a registered trademark of The Apache Software Foundation and has been licensed for use by OVHcloud, who has no affiliation with and is not endorsed by The Apache Software Foundation.
- MongoDB® is a registered trademark of MongoDB, Inc.
- MySQL® is a registered trademark of Oracle and/or its affiliates.
- PostgreSQL® is a registered trademark of the PostgreSQL Community Association of Canada.