Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to create MongoDB /data/db directory on macOS Catalina

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
like image 615
john doe Avatar asked Sep 17 '19 17:09

john doe


People also ask

Where is data directory for MongoDB?

MongoDB requires a data folder to store its files. The default location for the MongoDB data directory is c:\data\db.

How do you change the default Datafile directory of MongoDB?

Copy the data folder of your mongodb to the new location - cp -R /var/lib/mongodb/ /mnt/database/ Remove the old database folder - rm -rf /var/lib/mongodb/ Create symbolic link to the new database folder - ln -s /mnt/database/mongodb /var/lib/mongodb. Start mongod - /etc/rc.


1 Answers

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

like image 90
Alex Gold Avatar answered Oct 04 '22 03:10

Alex Gold