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

后端 未结 16 2071
予麋鹿
予麋鹿 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条回答
  • With macOS Catalina, you can no longer store files or data in the read-only system volume, nor can you write to the "root" directory ( / ) from the command line, such as with Terminal.

    0 讨论(0)
  • 2020-12-07 10:42

    I did this:

    mkdir -p usr/local/var/mongodb/data/db
    

    since the new path that is "usr/local/var/mongodb".

    0 讨论(0)
  • 2020-12-07 10:44

    You can't create a folder on the root directory on Mac Catalina anymore!

    https://www.apple.com/macos/catalina/features/

    Dedicated system volume

    macOS Catalina runs in a dedicated, read-only system volume — which means it is completely separate from all other data and helps improve the reliability of macOS.

    # macOS Catalina, mkdir path
    $ sudo mkdir -p /System/Volumes/Data/data/db
    
    # give permissions
    $ sudo chown -R `id -un` /System/Volumes/Data/data/db
    
    
    # macOS 10.14.x -
    $ sudo mkdir -p /data/db
    
    # macOS 10.15.x +
    $ sudo mkdir -p /System/Volumes/Data/data/db
    
    

    refs

    https://discussions.apple.com/thread/250720711

    https://zellwk.com/blog/install-mongodb/

    https://www.youtube.com/watch?v=DX15WbKidXY

    0 讨论(0)
  • 2020-12-07 10:47

    Default Paths for the mongodb-community Formula

    In addition to installing the MongoDB server and tool binaries, the mongodb-community formula creates:

    • a configuration file: /usr/local/etc/mongod.conf
    • a log directory path: /usr/local/var/log/mongodb
    • a data directory path: /usr/local/var/mongodb

    then it worked for me:

    mkdir -p usr/local/var/mongodb/data/db
    
    0 讨论(0)
  • 2020-12-07 10:50

    Mac version Catalina made the root folder is no longer writable.

    Brew has an updated version of mongodb to use a new path (which it creates itself), /usr/local/var/mongodb and following these instructions will fix the issue:

    Guide to installing updated mongodb-community-edition

    brew install mongodb-community@VERSION where the first VERSION with the fix is 4.2

    0 讨论(0)
  • 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)

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