Install Mongodb Catalina

14th Feb 2020

Install Mongodb Catalina

I had to reconfigure my Macbook after sending it for repairs. During the reconfiguration period, I noticed the instructions I linked to in “Setting up a local MongoDB connection” were outdated.

Here’s an updated version on how to install MongoDB on a Mac.

I recently upgrade my Mac OS Sierra to Catalina and realize that the mongoDB was not usable in Catalina, somehow `brew update` and `brew upgrade` did not update the mongoDB to be able to run on Catalina. Below is a guide to fix it. The problem is related to the latest major macOS release, Catalina, and in this article, I’ll share my solution. Install MongoDB. Brew install mongodb-community or brew install mongodb. Before you can use MongoDB, you need to create a /data/db folder because MongoDB expects this directory (/data/db) on your machine to save the data. But Apple has already depreciated this directory on Catalina/BigSur machines and created a new volume on macOS Catalina. MongoDB expects the Data/data/db folders to be in a location which Mac OS Catalina does not allow. As a consequence the folders must be placed elsewhere, on one of the disk volumes. But modifying the MongoDB settings to find the new data folders is not working properly. There are many supposed solutions for this in various places on the web but none of them have solved my issues. Download & Install MongoDB on Windows. The following steps can be used to install MongoDB on Windows 10. Step 1) Go to link and Download MongoDB Community Server. We will install the 64-bit version for Windows. Step 2) Once download is complete open the msi file. Click Next in the start up screen.

There are a few steps:

First, you install Homebrew. If you’re curious about what Homebrew is, read this article.

Second, find the MongoDB tap.

Third, install MongoDB.

MongoDB is now installed on your computer.

Preparations (Before MacOS Catalina)

Before you can use MongoDB, you need to create a /data/db folder on your computer to use MongoDB. You can create this folder with the following command:

You also need to give permissions to use it:

Catalina

Now you can follow the rest of the article to set up your MongoDB connection.

Preparations (MacOS Catalina onwards)

Apple created a new Volume in Catalina for security purposes. If you’re on Catalina, you need to create the /data/db folder in System/Volumes/Data.

Use this command:

Then, use this command to give permissions:

Using MongoDB

In the past, I can run the mongod command to start MongoDB. This no longer works out for the box from MongoDB v4.2.3 onwards.

The best way to start MongoDB now is via brew services.

Starting MongoDB

Catalina

Use this command:

MongoDB will start as a background service. Here’s what you’ll see:

You can use start instead of run. start will start MongoDB automatically when you login into your Macbook. I prefer run since I don’t want MongoDB to be running all the time.

Checking if MongoDB is running

Use this command:

Install

Homebrew will list all running services. If MongoDB is running, mongodb-community will have a status set to started.

The Mongo Shell

Install mongodb osx catalina

If MongoDB is running, you should be able to access the Mongo shell with the mongo command.

Stopping MongoDB

Install Mongodb Catalina Operating System

Use this command:

Install Mongodb Catalina Mac

Homebrew will stop MongoDB and let you know.

Install Mongodb Osx Catalina

Aliases to make these easier

It’s a chore typing brew services run mongodb-community every time I want to start MongoDB.

I created some aliases to make things easier for me. Here are my aliases:

What’s next?

Install Mongodb Mac Catalina

If you haven’t already, you should learn how to set up a local MongoDB connection.

Install Mongodb Macos Catalina

If you enjoyed this article, please tell a friend about it! Share it on Twitter. If you spot a typo, I’d appreciate if you can correct it on GitHub. Thank you!