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 commented Nov 9, 2014

It works now! thanks for this!

@liubo2055

This comment has been minimized.

Copy link

liubo2055 commented Nov 16, 2014

Thanks a lot!!

@andrewabogado

This comment has been minimized.

Copy link

andrewabogado commented Nov 20, 2014

Thanks. Works.

@yogeshb79

This comment has been minimized.

Copy link

yogeshb79 commented Nov 21, 2014

Thanks .It works

@hootsieroll

This comment has been minimized.

Copy link

hootsieroll commented Mar 23, 2015

Yes!

@andrevvalle

This comment has been minimized.

Copy link

andrevvalle commented Mar 29, 2015

Thanks!

@miguekun

This comment has been minimized.

Copy link

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 commented May 17, 2015

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

@Donatoni

This comment has been minimized.

Copy link

Donatoni commented Jun 5, 2015

Big help! Thanks!

@mateorider

This comment has been minimized.

Copy link

mateorider commented Jun 26, 2015

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

@scwood

This comment has been minimized.

Copy link

scwood commented Jul 4, 2015

Appreciate this.

@howlomogo

This comment has been minimized.

Copy link

howlomogo commented Jul 17, 2015

Thank you

@troyling

This comment has been minimized.

Copy link

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 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 commented Aug 5, 2015

Awesome. This saved my bacon. Thank you!

@smokinjoe

This comment has been minimized.

Copy link

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 commented Sep 21, 2015

@miguekun Run mongod as sudo ./mongod

@YoEugene

This comment has been minimized.

Copy link

YoEugene commented Sep 26, 2015

Appreciate this.

@karatechops

This comment has been minimized.

Copy link

karatechops commented Nov 5, 2015

Really helpful. Thanks for this,.

@guoluona

This comment has been minimized.

Copy link

guoluona commented Nov 20, 2015

Really appreciate it!

@kersteinperez

This comment has been minimized.

Copy link

kersteinperez commented Nov 25, 2015

THANK YOU, THANK YOU, THANK YOU.

@hanachan1026

This comment has been minimized.

Copy link

hanachan1026 commented Dec 17, 2015

I really appreciate this!!! Thanks !!

@sitanshu-zymr

This comment has been minimized.

Copy link

sitanshu-zymr commented Dec 18, 2015

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

@MunveerGill

This comment has been minimized.

Copy link

MunveerGill commented Jan 17, 2016

Thanks!!

@zeevj

This comment has been minimized.

Copy link

zeevj commented Jan 24, 2016

Thank you! :)

@Wang-Kai

This comment has been minimized.

Copy link

Wang-Kai commented Feb 2, 2016

Thank you very much ...

@guilhermefsousa

This comment has been minimized.

Copy link

guilhermefsousa commented Feb 2, 2016

@troyling thanks

@baruchvlz

This comment has been minimized.

Copy link

baruchvlz commented Feb 13, 2016

This helped on Mac 10.11

@alexandr-g

This comment has been minimized.

Copy link

alexandr-g commented Feb 18, 2016

Great! As simple as it should be. Thanks!

@kiranmca04

This comment has been minimized.

Copy link

kiranmca04 commented Feb 19, 2016

Thank you

@raymondluong

This comment has been minimized.

Copy link

raymondluong commented Feb 22, 2016

This solved my problem. Thanks so much!

@nikhilmgoel

This comment has been minimized.

Copy link

nikhilmgoel commented Feb 24, 2016

this helped, thanks

@OlehHappy

This comment has been minimized.

Copy link

OlehHappy commented Feb 24, 2016

Thanks. Perfect. Works for me.

@lordwater

This comment has been minimized.

Copy link

lordwater commented Feb 26, 2016

Thanks

@nix19

This comment has been minimized.

Copy link

nix19 commented Feb 26, 2016

Thanks, this was such a lifesaver! :)

@SirLaurynas

This comment has been minimized.

Copy link

SirLaurynas commented Mar 4, 2016

Thanks, it works!

@JorgeAGomez

This comment has been minimized.

Copy link

JorgeAGomez commented Mar 9, 2016

Thanks! Very useful!

@harishca

This comment has been minimized.

Copy link

harishca commented Mar 20, 2016

Thank you very much

@MaynardTool

This comment has been minimized.

Copy link

MaynardTool commented Mar 21, 2016

Thanks very much!

@dijonkitchen

This comment has been minimized.

Copy link

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 commented Mar 22, 2016

Thanks 👍

@alhertz

This comment has been minimized.

Copy link

alhertz commented Apr 5, 2016

My effin hero

@OrganicChem

This comment has been minimized.

Copy link

OrganicChem commented Apr 21, 2016

Excellent!! Thanks for sharing.

@huangguangkai

This comment has been minimized.

Copy link

huangguangkai commented Apr 28, 2016

thanks, work for me!

@LiebeG

This comment has been minimized.

Copy link

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 commented May 22, 2016

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

@zhangjuncare

This comment has been minimized.

Copy link

zhangjuncare commented May 25, 2016

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

@farzamvat

This comment has been minimized.

Copy link

farzamvat commented Jun 3, 2016

thanks

@elliotte

This comment has been minimized.

Copy link

elliotte commented Jun 11, 2016

Gr8 thx

@Dane456

This comment has been minimized.

Copy link

Dane456 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 commented Jul 27, 2016

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

@hecside

This comment has been minimized.

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

This comment has been minimized.

Copy link

minachuong commented Aug 24, 2016

This was amazeballs. thanks so much!

@Lanceloft

This comment has been minimized.

Copy link

Lanceloft commented Aug 25, 2016

thank you very much

@abhirohan

This comment has been minimized.

Copy link

abhirohan commented Sep 1, 2016

thank you very much. :) Its working :)

@songbbb1

This comment has been minimized.

Copy link

songbbb1 commented Sep 6, 2016

Thanks

@maravilhosinga

This comment has been minimized.

Copy link

maravilhosinga commented Sep 8, 2016

This helped thanks alot

@muthugit

This comment has been minimized.

Copy link

muthugit commented Sep 9, 2016

Thanks it helps me

@rajesh-gonuguntla

This comment has been minimized.

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

This comment has been minimized.

Copy link

elimcjah commented Nov 10, 2016

+1 Thanks.

@atorscho

This comment has been minimized.

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

This comment has been minimized.

Copy link

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 commented Jan 6, 2017

Thank you!

@safaorhan

This comment has been minimized.

Copy link

safaorhan commented Jan 11, 2017

Thanks a lot!

@lwjameson

This comment has been minimized.

Copy link

lwjameson commented Feb 15, 2017

Fantastic! Thanks.

@heyitsjhu

This comment has been minimized.

Copy link

heyitsjhu commented Apr 9, 2017

Thanks for this!

@Atlas-zqh

This comment has been minimized.

Copy link

Atlas-zqh commented Apr 27, 2017

Thanks!

@kristynrb

This comment has been minimized.

Copy link

kristynrb commented May 13, 2017

thanks! 👍

@mltbnz

This comment has been minimized.

Copy link

mltbnz commented Jun 20, 2017

✌️ Thanks

@GiselleC

This comment has been minimized.

Copy link

GiselleC commented Jan 28, 2018

Thanks!!!

@anvarbey

This comment has been minimized.

Copy link

anvarbey commented Jan 29, 2018

You are very useful to humans , keep alive!

@GitPatrickHarris

This comment has been minimized.

Copy link

GitPatrickHarris commented Apr 6, 2018

This is huge, thank you so much.

@Harkishen-Singh

This comment has been minimized.

Copy link

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 commented Aug 21, 2018

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

@lfhwnqe

This comment has been minimized.

Copy link

lfhwnqe commented Sep 29, 2018

thanks so much

@falehenrique

This comment has been minimized.

Copy link

falehenrique commented Nov 22, 2018

thanks, it works to me.

@HarrisonFok

This comment has been minimized.

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

This comment has been minimized.

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