简体   繁体   中英

Windows 10 Linux Subsystem. How to install MongoDB

Recently published a new update to the Windows 10 Anniversary Update includes Linux Subsystem based on Ubuntu 14.04 and now I want to all of my working environment was in this Linux Subsystem.

I try to install MongoDB with this instructions from official website https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927
echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list
sudo apt-get update
sudo apt-get install -y mongodb-org

After installation is complete I try to run mongodb with

sudo service mongodb start

but have follow error

User@DESKTOP-TPQIRNP:/mnt/c/Users/User$ sudo service mongod start
initctl: Unable to connect to Upstart: Failed to connect to socket /com/ubuntu/upstart: Connection refused
mongod: unrecognized service

How to install the latest stable version of MongoDB without errors ?

At the moment, we can see some solutions to this problem in this Microsoft/BashOnWindows issue here https://github.com/Microsoft/BashOnWindows/issues/796

One of the working solutions https://github.com/Microsoft/BashOnWindows/issues/796#issuecomment-238048520

I was able to fix the

mongod: unrecognized service

issue by performing following tasks:

sudo nano /etc/init.d/mongod

then copy and paste the content from this url and save it (you can use vim or any other text editor)

After that give executable permission

sudo chmod +x /etc/init.d/mongod

Now you will be able to start the service by following command

sudo service mongod start

Just ignore the error and keep going. From here , the explanation:

this error can be safely ignored. WSL doesn't use Upstart to start processes at system boot. If you work closely with Upstart, this might cause some surprises for you; the message is informative to people who work directly with initctl, upstart, etc that WSL doesn't yet expose that functionality. If that's not your use case, then as you have observed, mongodb itself works.

Keep in mind that WSL is still beta and errors will be everywhere!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM