2

Hi I have problem when I run

mongod

This is what I got

2016-02-09T21:54:40.631-0700 I -        [initandlisten] Detected data files in /data/db created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.

2016-02-09T21:54:40.633-0700 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
2016-02-09T21:54:40.633-0700 I CONTROL  [initandlisten] dbexit:  rc: 100

I try everything uninstall mongo. Install with brew. Uninstall with brew etc. Change the permission of my data folder and get always the same problem.

EQuimper
  • 5,811
  • 8
  • 29
  • 42

5 Answers5

7

So this is what I did. I delete the /data/db folder after a recreate it with

sudo mkdir -p /data/db

Change the permission of data and db folder

mongod

everything working. My error was I didn't change the permission before I run mongod for the first time now everything is working fine.

EQuimper
  • 5,811
  • 8
  • 29
  • 42
  • I know this is old, but on newer macs it's changed: https://stackoverflow.com/questions/58283257/mongodb-cant-find-data-directory-after-upgrading-to-mac-os-10-15-catalina – lko Mar 15 '22 at 23:08
5

I was having the same issues until I ran

sudo chown -R 'youruserid' /data/db

it seems some file(s) in the directory still had the wrong permissions.

4

I think I had a similar problem with my mongo install in my Mac. Have you tried changing the owner of /db/data?

You can check who owns this directory (where the databases are stored) by writing the following command in the terminal.

ls -al /data/db

If the owner (the name in the third column) is not your user, change it with a chown command or try running mongod with sudo.

suecarmol
  • 467
  • 9
  • 18
  • `2016-02-09T22:50:54.575-0700 I CONTROL [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000` – EQuimper Feb 10 '16 at 05:53
  • If you are using mongo on your Mac for development purposes, then it's ok. You can check more at https://docs.mongodb.org/manual/reference/ulimit/ – suecarmol Feb 10 '16 at 15:32
  • I still suggest you change the owner of the /data/db directory. I do not recommend having to use sudo when you run the mongod command. – suecarmol Feb 10 '16 at 15:43
0

I would first check to see if you have another instance of mongo running as it suggests. If you do not - remove the lock file in question and try to launch mongo again. It is possible the lock file is a remnant of a previous install.

Jake Dempsey
  • 6,264
  • 1
  • 30
  • 25
-1
  1. systemctl enable mongod.service
    Start mongod service at system startup

  2. service mongod start

AlessioX
  • 3,167
  • 6
  • 24
  • 40