I installed MongoDB in wsl using the official windows document here.
I have created a path and can start the a DB instance using
sudo mongod --dbpath ~/data/db
but after following the docs further and adding the init script from here to start MongoDB as a service, and running this command
sudo service mongodb start
returns output:
* Starting database mongod [fail]
and as expected when I run,
sudo service mongodb status
I have the output
* Checking status of database mongod
* apparently not running
[fail]
now, how do I solve this?
2
Answers
I suppose you do something like this
wget -qO – https://raw.githubusercontent.com/mongodb/mongo/master/debian/init.d > /etc/init.d/mongod && chmod +x /etc/init.d/mongod
I had this problem to. At the time of writing the HEAD of that file seems broken. You can try:
wget -qO – https://raw.githubusercontent.com/mongodb/mongo/cad54eb5ebdff24ecec53b56788cd151d8d64272/debian/init.d > /etc/init.d/mongod && chmod +x /etc/init.d/mongod
to get the previous version
I was getting the same error.
I think owner for this file was root.
when I checked
ls -l
inside/var/run
directoryI got this
sudo chown mongodb:mongodb /var/run/mongod.pid
after running this issue was resolved