Mongodb service won't start
After running the repair I was able to start the mongod proccessor but as root, which meant that service mongod start
would not work. To repair this issue, I needed to make sure that all the files inside the database folder were owned and grouped to mongod. I did this by the following:
- Check the file permissions inside your database folder
- note you need to be in your dbpath folder mine was
/var/lib/mongo
I went tocd /var/lib
- I ran
ls -l mongo
- note you need to be in your dbpath folder mine was
- This showed me that databases were owned by root, which is wrong. I ran the following to fix this:
chown -R mongod:mongod mongo
. This changed the owner and group of every file in the folder to mongod. (If using the mongodb package,chown -R mongodb:mongodb mongodb
)
I hope this helps someone else in the future.
I solved this by executing C:\mongodb\bin\mongod.exe --repair
first. Then when I ran MongoDB again by C:\mongodb\bin\mongod.exe
, it successfully started.
I solved this by deleting d:\test\mongodb\data\mongod.lock file. When you will reconnect mongo db than this file will auto generate in same folder. it works for me.