The user account that is starting MongoDB needs to have write privileges to the /data/db/
directory ... you can change this like so ...
This command will change the owner of the /data/db/
to the user account being used.
$ sudo chown `id -u` /data/db
$ mongod
If you still run into problems with MongoDB starting, you need to delete /data/db/mongod.lock
and then run repair on your database ...
mongod --repair
More about the repair command here.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…