I created /data/db
in root directory and ran ./mongod
:
[initandlisten] exception in initAndListen: 20 Attempted to create a lock fi
If you are checking your mongodb logs and you are getting such an error then just follow steps as i did. It occurs due to permission issues with your /data/db
directory. I am using ubuntu16.04 and I find solution with running two simple commands as follow.
Step 1: Give permission to /data/db directory:
sudo chmod -R 0777 /data/db
Step 2: Try to start mongod service as :
sudo service mongod start
Step 3: Check status of mongod service:
sudo service mongod status
This worked for me in Ubuntu LTS 20.04:
$ sudo service mongod start