Unable to create MongoDB /data/db directory on mac

2020-08-17 17:54发布

问题:

I get the following error when I try to create the MongoDB data/db directory:

sudo mkdir -p /data/db 


mkdir: /data/db: Read-only file system

回答1:

The remount didn't work for me (it requires Disabling SIP, which I didn't want to do) So instead I moved the mongo folder. You should have the old folder under the 'Relocated items' folder on your desktop so just copy it wherever you want (I moved it to my user folder) and then in the terminal go

mongod --dbpath /users/<username>/data/db/

hope this helps



回答2:

Problem because of Read-only file system in mac os catalina

  1. Boot you mac system into recovery mode. (by bootup system with holding CMD+R).

  2. Open terminal (Present in "Utilities" in the top left menu).

  3. Just run command

    csrutil disable

  4. Restart your system and Bootup normally

  5. Before doing any activity open terminal and run command.

    sudo mount -uw /

Once this all done you can do write in root location



回答3:

See the following answer: https://superuser.com/questions/1458974/macos-switched-root-mongodb-data-folder-to-system-ownership-and-it-cannot-be-cha

You have to create the directory in /System/Volumes/Data now.