Install Mongodb On Mac Catalina

  1. Install Mongodb On Mac Catalina Operating System
  2. Install Mongodb On Mac Catalina Island
  3. How To Install Mongodb On Macos Catalina
  4. Install Mongodb On Mac Catalina Download

I recently bought a new iMac and moved all of my files over using Time Machine. The migration went really well overall and within a few hours I had my development machine up and running. After starting an application I’m building I quickly realized that I couldn’t get MongoDB to start. Running the following command resulted in an error about the data/db directory being read-only:

I tried every chmod and chown command known to man and woman kind, tried manually changing security in Finder, compared security to my other iMac (they were the same), and tried a bunch of other things as well. But, try as I might I still saw the read-only folder error when trying to start the server….very frustrating. I found a lot of posts with the same issue but they all solved it by changing security on the folder. That wasn’t the problem on my machine.

After doing more research I found out that Catalina added a new volume to the hard drive and creates a special folder where the MongoDB files need to go. The new folder is:

In this article, I will share how to install MongoDB on MacOS Catalina. First, I created a directory under the Library folder as shown below. Mac version Catalina made the root folder is no longer writable. Brew has an updated version of mongodb to use a new path (which it creates itself), /usr/local/var/mongodb and following these instructions will fix the issue: Guide to installing updated mongodb-community-edition. Brew install email protected where the first VERSION with the.

The MongoDB files can then go at:

I ran the following commands to install the latest version of MongoDB using Homebrew (see https://github.com/mongodb/homebrew-brew for more details):

I then went into the MongoDB config file at /usr/local/etc/mongod.conf. Note that it’s possible yours may be located in a different location based on how you installed MongoDB. I changed the dbPath value to the following and copied my existing DB files into the folder:

Finally, I made sure my account had the proper access to the folder by running chown (something I had tried many times earlier but on a folder outside of /System/Volumes/Data):

After that I was able to start MongoDB and everything was back to normal. Hopefully this saves someone a few hours – I wasted way too much time on the issue. 🙂



14th Feb 2020

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.

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

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:

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

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.

Install Mongodb On Mac Catalina Operating System

Checking if MongoDB is running

Use this command:

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

Install Mongodb On Mac Catalina Island

The Mongo Shell

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

Stopping MongoDB

Use this command:

Homebrew will stop MongoDB and let you know.

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?

How To Install Mongodb On Macos Catalina

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

Install Mongodb On Mac Catalina Download

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!