'can't start mongodb server in ubuntu windows
i just install mongodb on ubuntu windows using sudo apt-get -y install mongodb
. after installation was finsished, i want to start using sudo systemctl start mongodb
and it show like this in terminal
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down
then i found the alternative way to start the server in this answer. i Tried using sudo /etc/init.d/mongodb start
and it gave me error like this
* Starting database mongodb [fail]
i think it's failed to start the server.
anyone can help me to solve this issue ? thanks in advance !
Solution 1:[1]
First of all, Thanks David Makogo for guiding to formulate a proper answer , I too had same problem and sorted out following couple of steps, therefore thought to share the steps and information related to this issue
Based on the support of underlying OS's built-in init System (a service management system in Linux)
we can perform/execute systemctl or service commands
Mainly, There are two types : namely systemd (systemctl) or System V Init (service)
WSL installed Ubuntu falls into init category , Anyway, you can check which type it by
**ps --no-headers -o comm 1**
Currently ,WSL does not support for systemd and no default scripts installed during installation of mongoDB
Anyway, we can execute service commands but we have to install init scripts beforehand, you can download & set permissions
**curl https://raw.githubusercontent.com/mongodb/mongo/master/debian/init.d |
sudo tee /etc/init.d/mongodb >/dev/null
sudo chmod +x /etc/init.d/mongodb**
Also create & set directories where you want to store data
**mkdir -p ~/data/db
mongod --dbpath ~/data/db #set to path while running mongo**
Next you can attempt the service commands based on success of all above points
**sudo service mongodb start/stop/status**
Also you can refer official microsoft guides for install mongoDB and differences
Solution 2:[2]
Refer this
it contains how to install MongoDB (version 5.0) on WSL (Ubuntu 20.04): avoiding wsl systemd issues as it currently does not support
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | SNL |
Solution 2 | SNL |