Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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/
@elliotte
Copy link

elliotte commented Jun 11, 2016

Gr8 thx

@danejordan
Copy link

danejordan commented Jul 9, 2016

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

@hecside
Copy link

hecside commented Jul 27, 2016

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

@hecside
Copy link

hecside commented Jul 27, 2016

UPDATE:

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.
source: http://stackoverflow.com/questions/7948789/mongodb-mongod-complains-that-there-is-no-data-db-folder

@minachuong
Copy link

minachuong commented Aug 24, 2016

This was amazeballs. thanks so much!

@Lanceloft
Copy link

Lanceloft commented Aug 25, 2016

thank you very much

@abhirohan
Copy link

abhirohan commented Sep 1, 2016

thank you very much. :) Its working :)

@songbbb1
Copy link

songbbb1 commented Sep 6, 2016

Thanks

@maravilhosinga
Copy link

maravilhosinga commented Sep 8, 2016

This helped thanks alot

@muthugit
Copy link

muthugit commented Sep 9, 2016

Thanks it helps me

@rajesh-gonuguntla
Copy link

rajesh-gonuguntla commented Oct 12, 2016

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

@elimcjah
Copy link

elimcjah commented Nov 10, 2016

+1 Thanks.

@atorscho
Copy link

atorscho commented Nov 27, 2016

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!

@floriangbh
Copy link

floriangbh commented Nov 29, 2016

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

@waltonryan
Copy link

waltonryan commented Jan 6, 2017

Thank you!

@safaorhan
Copy link

safaorhan commented Jan 11, 2017

Thanks a lot!

@lwjameson
Copy link

lwjameson commented Feb 15, 2017

Fantastic! Thanks.

@heyitsjhu
Copy link

heyitsjhu commented Apr 9, 2017

Thanks for this!

@Atlas-zqh
Copy link

Atlas-zqh commented Apr 27, 2017

Thanks!

@kristynrb
Copy link

kristynrb commented May 13, 2017

thanks! 👍

@mltbnz
Copy link

mltbnz commented Jun 20, 2017

✌️ Thanks

@GiselleC
Copy link

GiselleC commented Jan 28, 2018

Thanks!!!

@anvarbey
Copy link

anvarbey commented Jan 29, 2018

You are very useful to humans , keep alive!

@GitPatrickHarris
Copy link

GitPatrickHarris commented Apr 6, 2018

This is huge, thank you so much.

@Harkishen-Singh
Copy link

Harkishen-Singh commented May 25, 2018

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

@dazyang
Copy link

dazyang commented Aug 21, 2018

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

@lfhwnqe
Copy link

lfhwnqe commented Sep 29, 2018

thanks so much

@falehenrique
Copy link

falehenrique commented Nov 22, 2018

thanks, it works to me.

@HarrisonFok
Copy link

HarrisonFok commented Apr 19, 2019

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

@akashverma24
Copy link

akashverma24 commented Jun 21, 2019

Thank you. This works !!

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