Mongodb Install Mac Catalina

Question or issue on macOS:

I updated to MacOS 10.15 (Catalina) today. When I run mongod in the terminal it cannot find the /data/db directory:

I tried to install MongoDB with brew:

Recently, I started a new developer job and switched from a Windows to a Mac. The switch was mostly very smooth, with one main problem: setting up MongoDB. The problem is related to the latest major macOS release, Catalina, and in this article, I’ll share my solution. MongoDB Catalina. Installing MongoDB on Mac (Catalina and non-Catalina), Third, install MongoDB. Brew install mongodb-community. MongoDB is now installed on your computer. Preparations (Before MacOS Catalina). A general overview of MongoDB, providing a basic understanding of the database. The instructions we give on installing MongoDB here and other places.

Any help?

How to solve this problem?

Mongodb Install Mac Catalina

Solution no. 1:

This is the main error:


exception in initAndListen: NonExistentPath: Data directory /data/db not found., terminating

Catalina has a surprise change: it won’t allow changes to the root directory (this was discussed in a forum thread as well):

Unfortunately, this is not spelled out explicitly in Apple’s Catalina release notes, other than a brief mention in Catalina features:


macOS Catalina runs in a dedicated, read-only system volume

Since the directory /data/db is coded as MongoDB default, a workaround is to specify a different dbpath that is not located on the root directory. For example:

This will place MongoDB’s data in your home directory. Just make sure that the path ~/data/db actually exists.

Alternative method

An alternative method is to follow the instructions at Install MongoDB Community Edition on macOS by leveraging brew:

This will create some additional files by default:

  • the configuration file (/usr/local/etc/mongod.conf)
  • the log directory path (/usr/local/var/log/mongodb)
  • the data directory path (/usr/local/var/mongodb)

To run mongod you can either:

  • Run the command manually from the command line (this can be aliased for convenience):

  • Run MongoDB as a service using brew services. Note that this will run MongoDB as a standalone node (not a replica set), so features that depends on the oplog e.g. changestreams will not work unless you modify the mongod configuration file:

Solution no. 2:

After installing Catalina, you might have a folder on your Desktop called Relocated Items. You can find the data/db folder inside the Security folder.

All I had to do was move the Security/data/db, specifically data/db and place it inside my home folder.

You can do this with the Finder app or with the terminal by running the following command:

After that run:
mongod --dbpath ~/data/db

It’s up to you to create the alias

Solution no. 3:

Kevinadi already did justice to the question, however this is how I went about solving the problem:

After installing mongodb-community

  1. sudo mkdir -p /System/Volumes/Data/data/db (Create the data/db folder)
  2. sudo chown -Rid -un/System/Volumes/Data/data/db (Give permissions)
  3. mongod --dbpath=/System/Volumes/Data/data/db (Change dbpath of mongodb)
  4. mongod (Runs well)

I found this article on installing mongodb very useful

Solution no. 4:

found a trick…
delete the ~/data/db entire folder from the directory
then recreate a new one but DO NOT USE mkdir -p /data/db
instead, just use your trackpad to do it
use system way to create folder

this worked for me

Solution no. 5:

Here’s what worked for me:

  1. Create a folder somewhere e.g. Development/mongodb/data/db
  2. Open mongod.conf file and update storage.dbPath value to the the newly created folder path

Solution no. 6:

this script can be helpful https://gist.github.com/sturmenta/cf19baa91b1d79d8ae2b305fb7e1f799

🤙🏻🤙🏻🤙🏻

Solution no. 7:

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:

brew install [email protected] where the first VERSION with the fix is 4.2

Solution no. 8:

Your docker image will be able to find your directories regardless of where they are if you use relative directory references ~/Desktop will map your Mac Desktop directory into your image as /Desktop.

Solution no. 9:

Go to ~/Users/Shared folder.
here, you will find a folder titled ‘Relocated items’ inside that you will be able to find a ‘data’ folder.This ‘data folder contains your mongodb database in`/data/db’.

Now, copy this ‘data’ folder and paste it in your Users/<name-of-your-user-account-with-the-home-icon'>.

And now open zsh terminal and run mongod --dbpath ~/data/db and now open a new shell in a separate tab and type mongo to open the mongo shell and you will be good to go.

Remember to use mongod --dbpath ~/data/db each time while running mongod or make an alias.

Hope this helps!

In this tutorial, we present a step by step tutorial on how to install MongoDB on Mac OS.

The operating system considered for this tutorial is macOS 10.14 (Mojave).

1. Download the Community Edition of MongoDB from here: https://www.mongodb.com/download-center/community. It will be a TGZ file, something like mongodb-osx-ssl-x86_64-4.0.11.tgz

2. After completion of download, navigate to the /Downloads directory.

3. Extract the downloaded .tar file.

4. Now move the extracted directory to /usr/local/mongo

5. Navigate to /usr/local/mongo

Mongodb Install Macos Catalina

6. Now MongoDB needs a data directory to store data. By default, it stores at /data/db but you need to create it.

7. With the data directory created, you need to set the correct permissions. You first check and get your current username and set permissions to it.

9. Get back to the root directory.

10. List all files, including those starting with .

11. If you already find the .bash_profile file listed, open it. If not, create and open it.

12. Copy the following two lines of code and append at the end of the file.

13. Save the changes, press CTRL + S.

14. Restart the terminal, or read and execute the .bash_profile file again

Install Mongodb Mac Catalina

15. If the installation is successful, the following command will give the version of MongoDB just installed on your system.

16. Now we get to work with MongoDB. The first is to run the Mongo Daemon mongod

Mongodb Install Mac Catalina Os

17. Next, open a new terminal window and start the Mongo shell

Mongodb Install Mac Catalina Free

This is where you will be typing your commands.