Read-only file system when attempting mkdir /data/db on Mac [closed]
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 mongodb-community@4.2
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
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)