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/
@rustanacexd

This comment has been minimized.

Copy link

@rustanacexd rustanacexd commented Nov 9, 2014

It works now! thanks for this!

@liubo2055

This comment has been minimized.

Copy link

@liubo2055 liubo2055 commented Nov 16, 2014

Thanks a lot!!

@andrewabogado

This comment has been minimized.

Copy link

@andrewabogado andrewabogado commented Nov 20, 2014

Thanks. Works.

@yogeshb79

This comment has been minimized.

Copy link

@yogeshb79 yogeshb79 commented Nov 21, 2014

Thanks .It works

@hootsieroll

This comment has been minimized.

Copy link

@hootsieroll hootsieroll commented Mar 23, 2015

Yes!

@andrevvalle

This comment has been minimized.

Copy link

@andrevvalle andrevvalle commented Mar 29, 2015

Thanks!

@miguekun

This comment has been minimized.

Copy link

@miguekun miguekun commented Apr 13, 2015

Hello, thanks for the information, the result of the
ls -ld /data/db in my case returns:
drwxr-xr-x 2 root wheel 68 Apr 12 19:14 /data/db
which looks good but still prompts the error: "I STORAGE [initandlisten] exception in initAndListen: 98 Unable to create/open lock file: /data/db/mongod.lock errno:13 Permission denied Is a mongod instance already running?, terminating"

Can you help me please, I cant find the wat yo make it work!
Thank you in advance

@a1GoXplorer

This comment has been minimized.

Copy link

@a1GoXplorer a1GoXplorer commented May 17, 2015

Oh my Science, thank you! This totally rigged my deal.

@Donatoni

This comment has been minimized.

Copy link

@Donatoni Donatoni commented Jun 5, 2015

Big help! Thanks!

@mateorider

This comment has been minimized.

Copy link

@mateorider mateorider commented Jun 26, 2015

You're a wizard, good sir. Thank you!

@scwood

This comment has been minimized.

Copy link

@scwood scwood commented Jul 4, 2015

Appreciate this.

@howlomogo

This comment has been minimized.

Copy link

@howlomogo howlomogo commented Jul 17, 2015

Thank you

@troyling

This comment has been minimized.

Copy link

@troyling troyling commented Jul 25, 2015

I am having the same issue as miguekun mentioned above. I am running OS X El Capitan version 10.11 beta though. Any one knows the work around? Thanks!

@troyling

This comment has been minimized.

Copy link

@troyling troyling commented Jul 25, 2015

Can't update my comment above for some reason...

Just figured out that I need permission for everything in the folder too. The following command works for me

sudo chown -R 'id -u' /data/db

@saddacracker

This comment has been minimized.

Copy link

@saddacracker saddacracker commented Aug 5, 2015

Awesome. This saved my bacon. Thank you!

@smokinjoe

This comment has been minimized.

Copy link

@smokinjoe smokinjoe commented Aug 11, 2015

@miguekun - FYI, you need to run mongod as sudo mongod and you won't get that error.

I was running into the issue myself. For my situation, I actually had to sudo mkdir -p /data/db so I'm assuming that's where the problem stemmed from.

@aravindderajan

This comment has been minimized.

Copy link

@aravindderajan aravindderajan commented Sep 21, 2015

@miguekun Run mongod as sudo ./mongod

@YoEugene

This comment has been minimized.

Copy link

@YoEugene YoEugene commented Sep 26, 2015

Appreciate this.

@karatechops

This comment has been minimized.

Copy link

@karatechops karatechops commented Nov 5, 2015

Really helpful. Thanks for this,.

@guoluona

This comment has been minimized.

Copy link

@guoluona guoluona commented Nov 20, 2015

Really appreciate it!

@kersteinperez

This comment has been minimized.

Copy link

@kersteinperez kersteinperez commented Nov 25, 2015

THANK YOU, THANK YOU, THANK YOU.

@hanachan1026

This comment has been minimized.

Copy link

@hanachan1026 hanachan1026 commented Dec 17, 2015

I really appreciate this!!! Thanks !!

@sitanshu-zymr

This comment has been minimized.

Copy link

@sitanshu-zymr sitanshu-zymr commented Dec 18, 2015

Thanks....
sudo chown $USER /data/db is necessary....

@MunveerGill

This comment has been minimized.

Copy link

@MunveerGill MunveerGill commented Jan 17, 2016

Thanks!!

@zeevj

This comment has been minimized.

Copy link

@zeevj zeevj commented Jan 24, 2016

Thank you! :)

@Wang-Kai

This comment has been minimized.

Copy link

@Wang-Kai Wang-Kai commented Feb 2, 2016

Thank you very much ...

@guilhermefsousa

This comment has been minimized.

Copy link

@guilhermefsousa guilhermefsousa commented Feb 2, 2016

@troyling thanks

@baruchvlz

This comment has been minimized.

Copy link

@baruchvlz baruchvlz commented Feb 13, 2016

This helped on Mac 10.11

@alexandr-g

This comment has been minimized.

Copy link

@alexandr-g alexandr-g commented Feb 18, 2016

Great! As simple as it should be. Thanks!

@kiranmca04

This comment has been minimized.

Copy link

@kiranmca04 kiranmca04 commented Feb 19, 2016

Thank you

@raymondluong

This comment has been minimized.

Copy link

@raymondluong raymondluong commented Feb 22, 2016

This solved my problem. Thanks so much!

@nikhilmgoel

This comment has been minimized.

Copy link

@nikhilmgoel nikhilmgoel commented Feb 24, 2016

this helped, thanks

@OlehHappy

This comment has been minimized.

Copy link

@OlehHappy OlehHappy commented Feb 24, 2016

Thanks. Perfect. Works for me.

@lordwater

This comment has been minimized.

Copy link

@lordwater lordwater commented Feb 26, 2016

Thanks

@nix19

This comment has been minimized.

Copy link

@nix19 nix19 commented Feb 26, 2016

Thanks, this was such a lifesaver! :)

@SirLaurynas

This comment has been minimized.

Copy link

@SirLaurynas SirLaurynas commented Mar 4, 2016

Thanks, it works!

@JorgeAGomez

This comment has been minimized.

Copy link

@JorgeAGomez JorgeAGomez commented Mar 9, 2016

Thanks! Very useful!

@harishca

This comment has been minimized.

Copy link

@harishca harishca commented Mar 20, 2016

Thank you very much

@MaynardTool

This comment has been minimized.

Copy link

@MaynardTool MaynardTool commented Mar 21, 2016

Thanks very much!

@dijonkitchen

This comment has been minimized.

Copy link

@dijonkitchen dijonkitchen commented Mar 21, 2016

Thanks for this! Don't know why it's not explicit in the MongoDB docs!

@aminnaggar

This comment has been minimized.

Copy link

@aminnaggar aminnaggar commented Mar 22, 2016

Thanks 👍

@alhertz

This comment has been minimized.

Copy link

@alhertz alhertz commented Apr 5, 2016

My effin hero

@OrganicChem

This comment has been minimized.

Copy link

@OrganicChem OrganicChem commented Apr 21, 2016

Excellent!! Thanks for sharing.

@huangguangkai

This comment has been minimized.

Copy link

@huangguangkai huangguangkai commented Apr 28, 2016

thanks, work for me!

@LiebeG

This comment has been minimized.

Copy link

@LiebeG LiebeG commented May 7, 2016

My output is right. Why I still have this problem?
Please help me.

@ReddyArun

This comment has been minimized.

Copy link

@ReddyArun ReddyArun commented May 22, 2016

sudo chown $USER /data/db
thanks, work for me!!

@zhangjuncare

This comment has been minimized.

Copy link

@zhangjuncare zhangjuncare commented May 25, 2016

谢谢,
sudo chown $USER /data/db
thanks, this work for me!!

@farzamvat

This comment has been minimized.

Copy link

@farzamvat farzamvat commented Jun 3, 2016

thanks

@elliotte

This comment has been minimized.

Copy link

@elliotte elliotte commented Jun 11, 2016

Gr8 thx

@danejordan

This comment has been minimized.

Copy link

@danejordan 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

This comment has been minimized.

Copy link

@hecside hecside commented Jul 27, 2016

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

@hecside

This comment has been minimized.

Copy link

@hecside 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

This comment has been minimized.

Copy link

@minachuong minachuong commented Aug 24, 2016

This was amazeballs. thanks so much!

@Lanceloft

This comment has been minimized.

Copy link

@Lanceloft Lanceloft commented Aug 25, 2016

thank you very much

@abhirohan

This comment has been minimized.

Copy link

@abhirohan abhirohan commented Sep 1, 2016

thank you very much. :) Its working :)

@songbbb1

This comment has been minimized.

Copy link

@songbbb1 songbbb1 commented Sep 6, 2016

Thanks

@maravilhosinga

This comment has been minimized.

Copy link

@maravilhosinga maravilhosinga commented Sep 8, 2016

This helped thanks alot

@muthugit

This comment has been minimized.

Copy link

@muthugit muthugit commented Sep 9, 2016

Thanks it helps me

@rajesh-gonuguntla

This comment has been minimized.

Copy link

@rajesh-gonuguntla rajesh-gonuguntla commented Oct 12, 2016

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

@elimcjah

This comment has been minimized.

Copy link

@elimcjah elimcjah commented Nov 10, 2016

+1 Thanks.

@atorscho

This comment has been minimized.

Copy link

@atorscho 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

This comment has been minimized.

Copy link

@floriangbh floriangbh commented Nov 29, 2016

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

@waltonryan

This comment has been minimized.

Copy link

@waltonryan waltonryan commented Jan 6, 2017

Thank you!

@safaorhan

This comment has been minimized.

Copy link

@safaorhan safaorhan commented Jan 11, 2017

Thanks a lot!

@lwjameson

This comment has been minimized.

Copy link

@lwjameson lwjameson commented Feb 15, 2017

Fantastic! Thanks.

@heyitsjhu

This comment has been minimized.

Copy link

@heyitsjhu heyitsjhu commented Apr 9, 2017

Thanks for this!

@Atlas-zqh

This comment has been minimized.

Copy link

@Atlas-zqh Atlas-zqh commented Apr 27, 2017

Thanks!

@kristynrb

This comment has been minimized.

Copy link

@kristynrb kristynrb commented May 13, 2017

thanks! 👍

@mltbnz

This comment has been minimized.

Copy link

@mltbnz mltbnz commented Jun 20, 2017

✌️ Thanks

@GiselleC

This comment has been minimized.

Copy link

@GiselleC GiselleC commented Jan 28, 2018

Thanks!!!

@anvarbey

This comment has been minimized.

Copy link

@anvarbey anvarbey commented Jan 29, 2018

You are very useful to humans , keep alive!

@GitPatrickHarris

This comment has been minimized.

Copy link

@GitPatrickHarris GitPatrickHarris commented Apr 6, 2018

This is huge, thank you so much.

@Harkishen-Singh

This comment has been minimized.

Copy link

@Harkishen-Singh Harkishen-Singh commented May 25, 2018

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

@dazyang

This comment has been minimized.

Copy link

@dazyang dazyang commented Aug 21, 2018

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

@lfhwnqe

This comment has been minimized.

Copy link

@lfhwnqe lfhwnqe commented Sep 29, 2018

thanks so much

@falehenrique

This comment has been minimized.

Copy link

@falehenrique falehenrique commented Nov 22, 2018

thanks, it works to me.

@HarrisonFok

This comment has been minimized.

Copy link

@HarrisonFok 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

This comment has been minimized.

Copy link

@akashverma24 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
You can’t perform that action at this time.