How to Install MongoDB on Your Mac

How to Install MongoDB on Your MacGet up and running as quickly as possibleTolu AdesinaBlockedUnblockFollowFollowingJun 12captured from MongoDB’s websiteFirst you need to check if you have Homebrew on your computer — brew help just in case you do not need it.

Homebrew is a package manager for MacOs.

/usr/bin/ruby -e "$(curl -fsSL https://raw.


com/Homebrew/install/master/install)"Paste the above code (from the Homebrew website) in your terminal.

When it is done running, you should run brew install wget in your terminal as well, to get the necessary dependencies.

You can run brew update and brew help also, to be sure all is well with Brew.

The TerminalNow that we have Homebrew installed, we can go ahead and install MongoDB, which is after all the reason you are reading this.

Run brew install mongodb again in your terminal — this will install MongoDB for us.

This next step might not be needed for everyone, but if you see this error:Error: The `brew link` step did not complete successfullyThe formula built, but is not symlinked into /usr/localCould not symlink bin/bsondumpTarget /usr/local/bin/bsondump.

You should do the following:brew unlink mongodb-community && brew link mongodb-communityPaste this in to your terminal — this will sync (link) the MongoDB properly.

One more step to completion is setting up the directory where your databases will be.

run: sudo mkdir -p /data/db.

You can check who you are by running this: whoami.

Then run this: sudo chown -R $(whoami) /data/db to give your user the right permissions to read and write from the DB.

Now that we are done.

run mongod to start the Mongo server.

You can then open another terminal window as a tab or independent window.

Run mongo on the new terminal, to be able to interact with your MongoDB database.

Run show dbs to see the current databases.

Thank you for your time.

I hope you’ve enjoyed reading this article.


. More details

Leave a Reply