Skip to content

Instantly share code, notes, and snippets.

Last active January 17, 2023 15:17
Show Gist options
  • Save adamgibbons/cc7b263ab3d52924d83b to your computer and use it in GitHub Desktop.
Save adamgibbons/cc7b263ab3d52924d83b to your computer and use it in GitHub Desktop.
Install MongoDB on Mac OS X 10.9

Install MongoDB with Homebrew

brew install mongodb
mkdir -p /data/db

Set permissions for the data directory

Ensure that user account running mongod has correct permissions for the directory:

sudo chmod 0755 /data/db
sudo chown $USER /data/db

Run MongoDB!

iTerm buffer 1: mongod
iTerm buffer 2: mongo

Note: If you get something like this:

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

It means that /data/db lacks required permission and ownership.

Run ls -ld /data/db/

Output should look like this (gibber is directory owner and wheel is group to which gibber belongs):

drwxr-xr-x  7 gibber  wheel  238 Aug  5 11:07 /data/db/
Copy link

Gr8 thx

Copy link

Note: If sudo chown /data/db is not working, use sudo chown -R /data/db. That fixed it for me!

Copy link

hecside commented Jul 27, 2016

where exactly do you make the "data/db" directory?

Copy link

hecside commented Jul 27, 2016


I had to run the line with sudo in-front like so: sudo mkdir -p /data/db

after this it asked for my password and i then was able to run MongoDB.

Copy link

This was amazeballs. thanks so much!

Copy link

thank you very much

Copy link

thank you very much. :) Its working :)

Copy link

songbbb1 commented Sep 6, 2016


Copy link

This helped thanks alot

Copy link

muthugit commented Sep 9, 2016

Thanks it helps me

Copy link

Thank you very much. Wasted a day figuring out what is wrong with my node application.

Copy link

+1 Thanks.

Copy link

I had to change sudo chown $USER /data/db to sudo chown -R $USER /data/db (added '-R' flag) to make it work.

But thanks!

Copy link

floriangbh commented Nov 29, 2016

Hello ! Thank you !
In my case : sudo chown -R $USER /data/configdb/ , make it work !

Copy link

Thank you!

Copy link

Thanks a lot!

Copy link

Fantastic! Thanks.

Copy link

Thanks for this!

Copy link


Copy link

thanks! 👍

Copy link

mltbnz commented Jun 20, 2017

✌️ Thanks

Copy link


Copy link

You are very useful to humans , keep alive!

Copy link

This is huge, thank you so much.

Copy link

This was the best of all, i have ever read on mongo prob...!

Copy link

dazyang commented Aug 21, 2018

Finally, this solved the problem I was having! Thanks so much.

Copy link

lfhwnqe commented Sep 29, 2018

thanks so much

Copy link

thanks, it works to me.

Copy link

How come it's still giving me an error when I ran all of these?

Permission denied src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp 416

Copy link

Thank you. This works !!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment