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

后端 未结 16 2073
予麋鹿
予麋鹿 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 11:04

    You cannot create a /data/ directory. That is reserved for the APFS filesystem. Check Bombich’s blog about this issue.

    0 讨论(0)
  • 2020-12-07 11:05

    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

    1. sudo mkdir -p /System/Volumes/Data/data/db
    2. sudo chown -R id -un /System/Volumes/Data/data/db

    Start MongoDB

    1. brew services run mongodb-community

    2. Enjoy

    0 讨论(0)
  • 2020-12-07 11:06

    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

    0 讨论(0)
  • 2020-12-07 11:06

    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"

    0 讨论(0)
提交回复
热议问题