Today I Learned

Start working with MongoDB on MacOS Catalina

When you’re trying to launch MongoDB deamon for the first time, you need to create /data/db and give it write permissions, Because otherwise you will be hit in the face with this error:

NonExistentPath: Data directory /data/db not found.

By default MongoDB deamon expects you to have that directory in / but it’s impossible to do in MacOS Catalina, due to internal changes in the OS, which made root path read-only.

To overcome that obstacle you can for example create /data/db in your user directory. To do that, just run this command:

$ mkdir -p ~/data/db && mongod --dbpath ~/data/db

Issue found by @drakeooonnnn