Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6813525
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:34:50+00:00 2026-05-26T20:34:50+00:00

I am using my new mac for the first time today. I am following

  • 0

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 and hour and finally :

mkdir -p data/db

worked. and when I “ls”, a directory of data and nested in it a db folder do 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

EDIT
Getting error message for

sudo chown mongod:mongod /data/db

chown: mongod: Invalid argument

Thanks, everyone!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T20:34:50+00:00Added an answer on May 26, 2026 at 8:34 pm

    You created the directory in the wrong place

    /data/db means that it’s directly under the ‘/’ root directory, whereas you created ‘data/db’ (without the leading /) probably just inside another directory, such as the ‘/root’ homedirectory.

    You need to create this directory as root

    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


    Note:

    MongoDB also has an option where you can create the data directory in another location, but that’s generally not a good idea, because it just slightly complicates things such as DB recovery, because you always have to specify the db-path manually. I wouldn’t recommend doing that.


    Edit:

    the error message you’re getting is “Unable to create/open lock file: /data/db/mongod.lock errno:13 Permission denied”. The directory you created doesn’t seem to have the correct permissions and ownership —
    it needs to be writable by the user who runs the MongoDB process.

    To see the permissions and ownership of the ‘/data/db/’ directory, do this:
    (this is what the permissions and ownership should look like)

    $ ls -ld /data/db/
    drwxr-xr-x 4 mongod mongod 4096 Oct 26 10:31 /data/db/
    

    The left side ‘drwxr-xr-x’ shows the permissions for the User, Group, and Others.
    ‘mongod mongod’ shows who owns the directory, and which group that directory belongs to.
    Both are called ‘mongod’ in this case.

    If your ‘/data/db’ directory doesn’t have the permissions and ownership above, do this:

    First check what user and group your mongo user has:

    # grep mongo /etc/passwd
    mongod:x:498:496:mongod:/var/lib/mongo:/bin/false
    

    You should have an entry for mongod in /etc/passwd , as it’s a daemon.

    sudo chmod 0755 /data/db
    sudo chown -R 498:496 /data/db    # using the user-id , group-id
    

    You can also use the user-name and group-name, as follows:
    (they can be found in /etc/passwd and /etc/group )

    sudo chown -R mongod:mongod /data/db 
    

    that should make it work..

    In the comments below, some people used this:

    sudo chown -R `id -u` /data/db
    sudo chmod -R go+w /data/db
    

    or

    sudo chown -R $USER /data/db 
    sudo chmod -R go+w /data/db
    

    The disadvantage is that $USER is an account which has a login shell.
    Daemons should ideally not have a shell for security reasons, that’s why you see /bin/false in the grep of the password file above.

    Check here to better understand the meaning of the directory permissions:

    http://www.perlfect.com/articles/chmod.shtml

    Maybe also check out one of the tutorials you can find via Google: “UNIX for beginners”

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've just created a new Windows XP VM on my Mac using VMware Fusion.
I'm new to Windows development and I have a question. I'm using a Mac
when using new Date,I get something like follows: Fri May 29 2009 22:39:02 GMT+0800
What is the time complexity of dynamic memory allocation using new, malloc, etc.? I
I'm a new ruby/rails user trying to get my mac set up for the
I am on a new mac and cannot get eclipse to install marketplace plugins
I am using Versions application for Mac Os. I am new to Versions. I
I am new to Mac OS X and is using version 10.6.5. JDK 1.6_u22
Suppose you create a new Mac OS Command Line Application using Xcode , which
While using new_list = my_list , any modifications to new_list changes my_list every time.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.