MongoDB setup on Mac Catalina

I am following a tutorial on setting up MongoDB on my system. When I try to make a directory by using a command as under:

                    sudo mkdir /data/db 

inside of /usr/local/ bin, I get the following error:

              mkdir: /data: No such file or directory

However this was possible on the older version of Mac OS I had. How should I go about solving this issue? Kindly help.


MacBook Pro 16", macOS 10.15

Posted on Feb 3, 2020 7:05 AM

Reply
Question marked as Top-ranking reply
6 replies
Question marked as Top-ranking reply

Feb 3, 2020 10:50 AM in response to sabahat70

So I used homebrew to install mongodb on my system following the article

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

However, calling the

mongod --datapath=/System/Volumes/Data/data/db 

hangs the process at a certain point. And so the new data/db path is not being set , therfore calling

mongod 

does not start the mongodb as it shuts down because that data/db does not exist for it.


But starting the service using the brew command

brew services mongodb-community 

starts it then calling

mongo

starts the shell.


Why is this happening?

Does brew create a /data/db somewhere?



Feb 3, 2020 9:30 AM in response to sabahat70

sabahat70 wrote:

Thanks! But what does
~
represent?


~ is your home directory.


macOS Catalina runs in a dedicated, read-only system volume

ref: * https://stackoverflow.com/questions/58283257/mongodb-cant-find-data-directory-after-upgrading-to-mac-os-10-15-catalina


Since the directory /data/db is coded as MongoDB default, a workaround is to specify a different dbpath that is not located on the root directory.


For example:

mongod --dbpath ~/data/db

This will place MongoDB's data in your home directory. Just make sure that the path ~/data/dbactually exists.


This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

MongoDB setup on Mac Catalina

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.