How to connect MongoDB Compass to Compose

Published

MongoDB Compass is a desktop tool from the developers of MongoDB which provides very modern front end to MongoDB databases. With a community edition now available, we'll show you how to use it with Compose databases.

With the appearance of a community version of MongoDB's Compass tool, people have been asking us how they can use the desktop database querying application with Compose MongoDB databases. We'll show how here, but first, let's introduce Compass.

Introducing MongoDB Compass

MongoDB Compass was introduced as part of MongoDB's commercial enterprise offering in 2016. It's a desktop tool, built as an Electron-based application, that can work with databases, collections, indexes and documents, viewing, creating, modifying and deleting them as needed. There's an ad-hoc query system with a visual explainer to analyze performance. There's a set of enterprise features like advanced authentication, schema analysis, real time stats and document validation available in the enterprise version.

In October last year, MongoDB created MongoDB Compass Community to sit alongside the enterprise version. This edition isn't open source and specifically lacks those enterprise features but it is free to use for all purposes, not just evaluation and development.

Which in turn has meant that at Compose, we've been asked "how do you use the Community Edition with Compose?" so let's answer that. The answer, by the way, also works for the enterprise edition.

Connecting with MongoDB Compass

After you have downloaded and installed MongoDB Compass Community edition, run it and you'll be asked to enter some details on how to connect.

The Compass Connect Screen

These are broken up into the various component parts, and, for whatever reason, Compass doesn't take a MongoDB URL or as Compose displays refers to it, a connection string.

We're going to assume that you've created an admin user called 'dboss' in the admin database with a password of 'dbossdrum'. If you go to the overview page of your Compose MongoDB, you'll see the Connection Info panel:

The Compose Connection Info

This contains nearly all the information we need. If we use the Connection String in the panel, we can use one of the two host names:

Connection String Hosts

and their matching ports:

Connection String Ports

Which gives us our hostname and port.

Host Name and Port

Next comes the Authentication. Set it to Username/Password and enter the user name, password and for explicitness, admin as the Authentication database:

Authentication Settings

We can skip the Replica Set Name and Read Preference fields and move on to the SSL settings. This needs to be set, for Compose, to Server Validation.

SSL Settings

For this to work, you need to have a copy of the SSL Certificate for the Compose deployment. If you look back at the Connection Info panel, just below it is the SSL Certificate (Self-Signed) panel. Click the Show Certificate button, authenticate and the panel will display certificate. Select the certificate's text, copy it and paste it into a local file using your preferred text editor. We'll save our example as compassexample.pem.

Now, go back to Compass, click on Select Files and select the file you just created.

SSL Certificate Setting

Ok, one last step to do. Give the settings a Favorite Name and click the Create Favorite button that appears when you do that. It'll add the settings we've just created into a sidebar of your preferred connections.

Making Favorites

Now we can click on the Connect button and, all being well, we're connected. Now, you can use Compass to query, browse, edit and analyze your data and queries.

Compass on Compose

Happy Compassing.


Read more articles about Compose databases - use our Curated Collections Guide for articles on each database type. If you have any feedback about this or any other Compose article, drop the Compose Articles team a line at articles@compose.com. We're happy to hear from you.

attribution Aaron Burden

Dj Walker-Morgan
Dj Walker-Morgan was Compose's resident Content Curator, and has been both a developer and writer since Apples came in II flavors and Commodores had Pets. Love this article? Head over to Dj Walker-Morgan’s author page to keep reading.

Conquer the Data Layer

Spend your time developing apps, not managing databases.