Notion app logo
Struggling to stay organized and effective? Learn to master your time and tasks with the Effectively Notion course!

How to Restore a MongoDB Database from Compass

How to restore a MongoDB Database from Compass (the MongoDB database UI tool).


I often find that I want to restore a MongoDB database locally from MongoDB (Preview database) Atlas to determine if I've made any breaking changes.

Restoring your MongoDB database

  1. Download a backup from MongoDB Atlas.
  2. Unzip the backup. In this case, I unzipped it to my Downloads directory as dump.
  3. run a Docker container with the following flags:
    • -p <TO>:<FROM> - To is the port that you are serving on your local machine and From is the container's process port for Mongo (unless specified otherwise, it's 27017)
    • -v <LOCAL DB DIRECTORY>:<DOCKER DB PATH> - Local DB Directory is where I unzipped the backup. Docker DB Path is the directory Mongo will use to serve a database. Unless specified otherwise, this is /data/db
      docker container run -p 27018:27017 -v $HOME/Downloads/dump:/data/db mongo:5.0.7

Accessing your MongoDB database

Now from Mongo Compass you should be able to connect to your locally running Mongo instance with this connection string:


Notice the 27018? In this case, because that's the port I designated for Mongo to serve from on my computer, this is the port I want to connect to.

Photo of Chase Adams

Hey, I'm Chase. I help aspiring entrepreneurs and makers turn their ideas into digital products and apps.


Vector Arrow Scribbles
banner image for figma vector arrows scribbles

A figma community project of vectorized hand-drawn arrows.

Go To Figma
Vector Line Scribbles
banner for figma vector line scribbles

A figma community project of vectorized hand-drawn lines.

Go To Figma
Vector Shape Scribbles
banner image of figma vector shapes scribbles

A figma community project of vectorized hand-drawn shapes.

Go To Figma

Subscribe to my Newsletter

Every other week I publish the Curiously Crafted newsletter.

In it, I explore the intersection of curiosity and craft: the people who make stuff, what they make and the way they pursue the craft of making.


I'm on almost all social media as @curiouslychase.

The curious logo of Chase Adams: glasses and a bow tie.stay curious.