Deploying a database doesn’t have to be complicated. Today, we’re covering how to set up a free cluster in MongoDB in five easy steps. We’ll create our cluster, secure it, connect with Compass, run our first query, and try a Natural Language Query. And we’re going to do it all in just three minutes, so we'd better get started.
Step 1: Log in and create a free cluster using the link in the description. You’ll need to make an organization and project, then click “Create” and choose the free tier. Give your cluster a name, pick the cloud provider and region that work for you, and turn on the option to load the sample dataset. Then click “Create deployment.”
Step 2: Set up your secure connection. MongoDB is always locked down out of the box, so it requires an IP address and a database user before it allows anyone to access your database. Your IP address will load automatically, but you’ll need to create a user. Enter a username and password you’ll remember — but don’t use ours; they’re super secret. Now your cluster is ready to connect.
Step 3: Connect with Compass, MongoDB’s free GUI. First, copy the connection string Atlas generates for Compass. Next, download Compass if you haven’t already — maybe grab some popcorn while you wait, but don’t go far. Once it’s ready, hit “New Connection,” and you’ll see a URI field to paste your connection string.
Your username should appear automatically, but you’ll need to type in your password. Once you’ve done that, hit “Connect,” and it’ll be time to test out your first cluster.
Hey, remember that popcorn from earlier? You might need a movie to go with that. Let’s check some out.
Step 4: Explore connections and run your first query. Click on the sample_mflix database and select “movies”. You’ll see over 20,000 documents in the collection — that’s a few too many to choose from. We should probably run a query to get more specific.
MongoDB queries look like simple JavaScript objects. For example, to find movies released after 2000, create a filter using the year field and the dollar-greater-than operator set to 2000. Run it, and you’ll get all matching documents instantly.
Now here’s the cool part: Natural Language Query is built into Compass. Just hit “Generate Query” and type what you want—like “movies with an IMDb rating greater than 7”—and Compass makes it a query. Run it, and you’ll see your results — ooo, Star Wars.
And that’s all it takes. You’ve created your first cluster, secured it, connected with Compass, and run your first queries. Don’t forget to check out the link in the description, and go build something great.