Read-only file system when attempting mkdir /data/db on Mac

后端 未结 16 2115
予麋鹿
予麋鹿 2020-12-07 10:28

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<

16条回答
  •  鱼传尺愫
    2020-12-07 10:51

    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:

    1. Change mongod directory :

      sudo mongod --dbpath /System/Volumes/Data/data/db

    2. Give it an alias to use it as mongod:

      alias mongod="sudo mongod --dbpath /System/Volumes/Data/data/db"

    3. 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)

提交回复
热议问题