Install Mongodb Mac Catalina

Question or issue on macOS:

How to install MongoDB on Catalina OS. Prerequisites: Catalina macOS; Familiarity with the command terminal on your Mac; Download the MongoDB installation files: MongoDB recommends that we use the more complete version of MongoDB Server, so we recommend downloading the MongoDB Enterprise version for macOS in TGZ format. Extract the files. Step 4 — Installing, Upgrading, and Removing Packages. Now that Homebrew is installed, use it to download a package. The tree command lets you see a graphical directory tree and is available via Homebrew. Install tree with the brew install command: brew install tree. 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.

I am trying to create a new folder in the main directory

Install

Tried all kinds of examples

sudo mkdir /data/db

sudo mkdir -p /data/db

I keep getting

How to solve this problem?

Solution no. 1:

If you have Mac and updated to Catalina than the root folder is no
longer writable.

I just changed the directory somewhere else.

Been using this command for now

Solution no. 2:

from the official docs https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/

install homebrew and run the following commands

sudo chown -R $(whoami) $(brew --prefix)/*

then

brew tap mongodb/brew

then

brew install [email protected]

and

brew services start mongodb-community

or

mongod --config /usr/local/etc/mongod.conf

then

ps aux | grep -v grep | grep mongod

and

mongo

to verify you can run show dbs in the mongo shell

Solution no. 3:

With the new macOS Catalina update, the folder /data/db becomes read-only, you cannot modify it. Follow this procedure to create a DB in another folder:

  1. Change mongod directory :

    sudo mongod --dbpath /System/Volumes/Data/data/db

  2. Give it an alias to use it as mongod:

    alias mongod='sudo mongod --dbpath /System/Volumes/Data/data/db'

  3. Just type mongod in your terminal, it should work.

Extra => If you need to give it current user rights, use this line of code :

sudo chown -R $(whoami) /System/Volumes/Data/data/db

(Just for info -> $(whoami) is just a variable that returns your current user)

Solution no. 4:

To make a permanent change of the path of mongod db folder.

Following these docs they say roughly this. If mongod is started with brew services:

It will use config file at path /usr/local/etc/mongod.conf

Install Mongodb Mac Catalina

To fix this, edit the config file:

Install mongodb mac catalina update

And change the dbPath e.g. to your home directory like this:

Save the file and restart mongod with brew:

Solution no. 5:

Install mongodb mac catalina

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

Follow these commands

  1. sudo mkdir -p /System/Volumes/Data/data/db
  2. sudo chown -R id -un /System/Volumes/Data/data/db

Start MongoDB

  1. brew services run mongodb-community

  2. Enjoy 😉

Solution no. 6:

This is what worked for me as I was undergoing a Udemy course:
1. Install HomeBrew by typing this into your terminal

  1. Move your old /data/db folder (if you want to backup your current dbs) into a non root folder and proceed with the next step

  2. Run in Terminal
    a) brew uninstall mongodb
    b) If needed run brew uninstall --force mongodb
    c) brew tap mongodb/brew
    d) brew install mongodb-community
    e) brew services start mongodb/brew/mongodb-community

  3. All you need now is to run mongo in the Terminal and you’ll see the mongo shell symbol >.

Please let me know if this works 😉
It took me almost 2 hours to figure it out, based on this article:
https://apple.stackexchange.com/questions/362883/mongodb-doesnt-work-after-update-to-macos-catalina-10-15

Cheers,
Radu

Install Mongodb Mac Catalina Os

Solution no. 7:

If you are on mac and facing the issue then below command is useful,
whoami variable will get the current user

Solution no. 8:

You can’t create a folder on the root directory on Mac Catalina anymore!

Install Mongodb Mac Catalina

Dedicated system volume


macOS Catalina runs in a dedicated, read-only system volume — which means it is completely separate from all other data and helps improve the reliability of macOS.

refs

Solution no. 9:

Default Paths for the mongodb-community Formula

In addition to installing the MongoDB server and tool binaries, the mongodb-community formula creates:

  • a configuration file: /usr/local/etc/mongod.conf
  • a log directory path: /usr/local/var/log/mongodb
  • a data directory path: /usr/local/var/mongodb

then it worked for me:

Install Mongodb Mac Catalina Free

Solution no. 10:

With macOS Catalina, you can no longer store files or data in the read-only system volume, nor can you write to the “root” directory ( / ) from the command line, such as with Terminal.

Install Mongodb Mac Catalina Update

Hope this helps!