Read-only file system when attempting mkdir /data/db on Mac [closed]
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
I keep getting
mkdir: /data: Read-only file system
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
mongod --dbpath=/Users/user/data/db
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
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)