I am trying to create a new folder in the main directory
Tried all kinds of examples
sudo mkdir /data/db
sudo mkdir -p /data/db<
You cannot create a /data/
directory. That is reserved for the APFS filesystem. Check Bombich’s blog about this issue.
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
sudo mkdir -p /System/Volumes/Data/data/db
sudo chown -R
id -un /System/Volumes/Data/data/db
Start MongoDB
brew services run mongodb-community
Enjoy
I am at a loss why Apple did that.. So now, we can not have any root level directory other than theirs ? This just doesn't make any sense and people creating with root privileges those folders know what they are doing
To add on to what David Buck wrote here, first you have to actually make the directory. You can do that with:
sudo mkdir /System/Volumes/Data/data/db
If you're getting this error:
"Error parsing command line: unrecognised option '--dbpath/System/Volumes/Data/data/db' try 'mongod --help' for more information"
after creating the alias, it's just because David Buck (while making a really helpful comment) missed a space in his answer.
To fix this, type
unalias mongod
and then type
alias mongod="sudo mongod --dbpath /System/Volumes/Data/data/db"