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.
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:
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:
and their matching ports:
Which gives us our hostname 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:
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.
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
Now, go back to Compass, click on Select Files and select the file you just created.
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.
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.
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 firstname.lastname@example.org. We're happy to hear from you.
attribution Aaron Burden