3
votes

I am totally a beginner with mac , I get this error while trying to open the server using mongod 10309 Unable to create/open lock file: /data/db/mongod.lock errno:13 Permission denied Is a mongod instance already running?, terminatin

4

4 Answers

14
votes

The error usually indicates that the lock file is still present from a previous run. That means that the mongod process is stil running, check:

ps auxwww | grep mongod

If it is not listed, then remove the lock file and start mongod again. If it is listed and unresponsive you may have to kill the process (assuming you cannot connect). Try a regular kill before a kill -9 etc.

If the process is not there, or you kill it successfully, remove the lock file and restart mongod - if you had journaling enabled everything should be fine. If not, you may need the repair operation suggested by Sean.

6
votes

Run sudo mongodbecause you need to have admin access. From there, you just need to type in a password.

5
votes

Do you have journalling enabled? If not, and your mongod instance crashed, then you may need to perform a recovery. In this case, what you should do is

  1. start mongod with the repair switch: mongod --repair. It will run, and then terminate having deleted the lock file.
  2. start mongod again normally.

Once you do this, I highly recommend that you enable journalling by using the --journal command line switch when you start mongod.

0
votes

If I remember way back when, you need to sudo mkdir /data: I believe that MongoDB will assume that the base directory that it needs exists and won't create it on its own.