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<
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.
I did this:
mkdir -p usr/local/var/mongodb/data/db
since the new path that is "usr/local/var/mongodb".
https://www.apple.com/macos/catalina/features/
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.
# macOS Catalina, mkdir path
$ sudo mkdir -p /System/Volumes/Data/data/db
# give permissions
$ sudo chown -R `id -un` /System/Volumes/Data/data/db
# macOS 10.14.x -
$ sudo mkdir -p /data/db
# macOS 10.15.x +
$ sudo mkdir -p /System/Volumes/Data/data/db
https://discussions.apple.com/thread/250720711
https://zellwk.com/blog/install-mongodb/
https://www.youtube.com/watch?v=DX15WbKidXY
Default Paths for the mongodb-community Formula
In addition to installing the MongoDB server and tool binaries, the mongodb-community formula creates:
then it worked for me:
mkdir -p usr/local/var/mongodb/data/db
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 mongodb-community@VERSION
where the first VERSION with the fix is 4.2
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:
Change mongod
directory :
sudo mongod --dbpath /System/Volumes/Data/data/db
Give it an alias to use it as mongod
:
alias mongod="sudo mongod --dbpath /System/Volumes/Data/data/db"
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)