Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Web Technology by (47.6k points)

I am using my new mac for the first time today. I am following the get started guide on the mongodb.org up until the step where one creates the /data/db directory. btw, I used the homebrew route.

So I open a terminal, and I think I am at what you called the Home Directory, for when I do "ls", I see folders of Desktop Application Movies Music Pictures Documents and Library.

So I did a

mkdir -p /data/db

first, it says permission denied. I kept trying different things for half an hour and finally :

mkdir -p data/db

worked. and when I "ls", a directory of data and nested in it a db folder does exist.

then I fire up mongod and it complains about not finding data/db

Have I done something wrong?

Now I have done the

sudo mkdir -p /data/db

and when I do a "ls" I do see the data dir and the db dir. inside the db dir though, there is absolutely nothing in it and when I now run mongod

Sun Oct 30 19:35:19 [initandlisten] exception in initAndListen: 10309 Unable to create/open lock file: /data/db/mongod.lock errno:13 Permission denied Is a mongod instance already running?, terminating Sun Oct 30 19:35:19 dbexit: Sun Oct 30 19:35:19 [initandlisten] shutdown: going to close listening sockets... Sun Oct 30 19:35:19 [initandlisten] shutdown: going to flush diaglog... Sun Oct 30 19:35:19 [initandlisten] shutdown: going to close sockets... Sun Oct 30 19:35:19 [initandlisten] shutdown: waiting for fs preallocator... Sun Oct 30 19:35:19 [initandlisten] shutdown: lock for final commit... Sun Oct 30 19:35:19 [initandlisten] shutdown: final commit... Sun Oct 30 19:35:19 [initandlisten] shutdown: closing all files... Sun Oct 30 19:35:19 [initandlisten] closeAllFiles() finished Sun Oct 30 19:35:19 [initandlisten] shutdown: removing fs lock... Sun Oct 30 19:35:19 [initandlisten] couldn't remove fs lock errno:9 Bad file descriptor Sun Oct 30 19:35:19 dbexit: really exiting now

2 Answers

0 votes
by (106k points)

To get rid of this error you need to create this directory as root

So , either you need to use sudo , e.g. sudo mkdir -p /data/db

Or you need to do su - to become superuser, and then create the directory with mkdir -p /data/db

0 votes
by (50.2k points)
edited by

You can either create the db folder manually by mkdir -p /data/db, You have to make sure that the /data/db directory has the right permissions.

Related questions

0 votes
1 answer
0 votes
2 answers
asked Oct 16, 2019 in Web Technology by Sammy (47.6k points)
0 votes
1 answer
0 votes
1 answer
asked Oct 18, 2019 in Web Technology by Sammy (47.6k points)
0 votes
2 answers

Browse Categories

...