Failed to start mongod.service: Unit mongod.service not found
Asked Answered
M

34

124

I follow all the steps mention in MongoDB installation documents for Ubuntu 16.04.

Steps 1:

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5

Steps 2:

echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.6 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.6.list

Steps 3:

sudo apt-get update

Steps 4:

sudo apt-get install -y mongodb-org

Steps 5:

sudo service mongod start

when I started MongoDB got an error as:

Failed to start mongod.service: Unit mongod.service not found.

Multifoil answered 4/1, 2018 at 9:35 Comment(1)
I has the same problem and the following answer was the only thing that worked for me: https://askubuntu.com/a/842599Homily
M
136

Most probably unit mongodb.service is masked. Use following command to unmask it.

sudo systemctl unmask mongod

and re-run

sudo service mongod start

Marinelli answered 19/2, 2018 at 21:58 Comment(9)
returns: Unit mongodb.service does not exist, proceeding anyway.Celsacelsius
@Celsacelsius you need to start mongod service sudo service mongod startMarinelli
@Marinelli even after using the above two commands the error is still the same as mentioned in the questionVacla
I cannot do sudo service mongod start since it also gives the following error: Failed to start mongod.service: Unit mongod.service not found. @MarinelliCelsacelsius
an important typo caused this answer to not work. please correct it. the proper unit name in Ubuntu is mongod not mongodb. so the right command to unmask it would be: sudo systemctl unmask mongod. thank you for your attention.Irate
For whatever reason, I had to say mongodb instead of mongod on Ubuntu 19.10.Colossus
On Ubuntu 18 it is mongodb and not mongod.Rivard
mongodb names are used in the outdated Ubuntu package, the official one uses mongod (for services, config etc). If you have /etc/mongodb.conf, most likely you have to uninstall the old package and install the official up-to-date one (similarly to what CodeGench has suggested, see my comment there too). If you have some date to save/migrate, take extra actoins to do soDierdredieresis
That's confusingBiannulate
C
73

Please follow the below steps, it should work.

1 - Uninstall current installation completely

Source - official instructions

sudo service mongod stop

Remove Packages

sudo apt-get purge mongodb-org*

Remove the folders

sudo rm -r /var/log/mongodb
sudo rm -r /var/lib/mongodb

2 - Reinstall as described on official site, I will just write down the all steps. enter link description here

Import the public key

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5

Create a list file for Ubuntu 16.04

echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.6 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.6.list

update the list

sudo apt-get update

Install the latest package

sudo apt-get install -y mongodb-org

3 - Now it should work, please try below command

sudo service mongod start

and check the status

mongo

it should appear the mongo shell

Charismatic answered 19/2, 2018 at 18:8 Comment(8)
For future readers who re-installed to no avail, this AskUbuntu answer is a better solution. It is unclear what the difference of this answer and OP's attempt as both point to same instructions link.Herr
It would be nice if @Parfait's comment was incorporated into the answer. Saved me an incredible amount of time.Celinacelinda
It works, I think the problem was that I did not install for the right ubuntu version (check it with lsb_release -a)Myeloid
2021 solution! Thanks budGilbertine
in my case, I installed the wrong unofficial packages from Ubuntu (sudo apt install mongodb-server). To remove those, I had to slightly modify the first 2 steps: sudo service mongodb stop and then sudo apt-get purge mongodb*Dierdredieresis
2022 solution as wellOphiology
Getting "Failed to enable unit: Unit file mongod.service does not exist." after I run the 1st commandVie
@SantanuBiswas probably Mongodb is not running on your system. You can skip the first command.Charismatic
C
50

You are missing a 'b' I think?

sudo service mongod start

should be

sudo service mongodb start

I think this is the case?

Compressor answered 4/1, 2018 at 9:41 Comment(4)
after running "sudo systemctl unmask mongodb" its working :)Multifoil
On ubuntu 18.04 if you installed from the system repo, then it's mongodb instead of mongodHeadstand
...and that installation from Ubuntu system repo is not recommended by official Mongo docs, it's quite outdated for nowDierdredieresis
there is no such things as mongodb - the things that get installed is a demon and its name is mongodPrefab
G
42

Failed to start mongod.service: Unit mongod.service not found

If you are following the official doc and are coming across with the error above that means mongod.service is not enabled yet on you machine (I am talking about Ubuntu 16.04). You need to do that using following command

sudo systemctl enable mongod.service

Now you can start mongodb using the following command

sudo service mongod start
Gratt answered 11/7, 2018 at 13:19 Comment(3)
Failed to execute operation: No such file or directory :(Groscr
This worked even though systemctl list-unit-files --type=service said mongod was already enabled. Strange.Boise
Getting "Failed to enable unit: Unit file mongod.service does not exist." after I run the 1st commandVie
T
14

[Solution]

Just type

sudo mongod

It will work.

Tigrinya answered 5/6, 2018 at 14:52 Comment(5)
if Failed to enable unit: Unit file mongod.service does not exist. this woulndn't help only if perm deny for mongo!Jackknife
@JobinMathew, Worked fine in 18.4 LTSSwagsman
Works for 16.04Groscr
Works for 20.04 toHatpin
Yeah but this doesn't run it as a daemon does it, bit useless for serversNationalist
U
10

Case with me

Worked fine after the install; this problem occurred after I rebooted.

What worked for me is

sudo mkdir /var/lib/mongodb 
sudo mkdir /var/log/mongodb 
sudo chown -R mongodb:mongodb /var/lib/mongodb 
sudo chown -R mongodb:mongodb /var/log/mongodb 

After running the above commands open a new terminal and run:

sudo systemctl restart mongod

and run the mongo shell to check:

mongo

Note

If this problem occurs again (as with me every time I reboot), make it as a shell script to be run at startup.

Permanent solution (shell script at startup)

Step 1:

Make a file in the /etc/init.d directory

sudo gedit /etc/init.d/custom-mongo-fix.sh

Step 2:

Put below code in the file you just opened in Step 1

#!/bin/bash

# mongodb fix
sudo mkdir /var/lib/mongodb 
sudo mkdir /var/log/mongodb 
sudo chown -R mongodb:mongodb /var/lib/mongodb 
sudo chown -R mongodb:mongodb /var/log/mongodb 

Step 3:

After the next boot you can normally start the mongod server by:

sudo systemctl start mongod

Explanation: mongodb requires the above two folders with owner as mongodb. When we shutdown/reboot, one or both of them gets removed. So, we need to create them and change their ownership.

Edit: I was using Stacer's cleaning tool before every shutdown. This also removes log files and folders. And hence, the error at every startup. Now I unselect the mongodb option and then clean.

Namaste. 🙏

Ultrared answered 27/3, 2021 at 20:15 Comment(1)
This is the only thing worked. Thanks man, you saved the day, really a GeniusTeakwood
A
8
service mongodb start
service mongodb status

the status is active when I started using above command

Abrasive answered 12/9, 2018 at 17:10 Comment(0)
S
8

For Ubuntu 16.04.5, it is noticed that MongoDB installations does not auto enable the mongod.service file after installation in my case after I have installed on several servers, so we need to enable it like below:

Issue below to check whether mongod is enabled

systemctl list-unit-files --type=service

If it shows as "disabled", then you need to enable it.

sudo systemctl enable mongod.service

If we want to see whether mongod.service file exists in case this file is missing, check in

ls /lib/systemd/system

You will see a file

/lib/systemd/system/mongod.service
Simba answered 30/11, 2018 at 8:13 Comment(1)
And if it's missing?Nationalist
A
8

This happened to me while adding users in admin db.

sudo systemctl daemon-reload 

is recommended from the official mongo website, but did not help.

If you get

Job for mongod.service failed because the control process exited with error code. See "systemctl status mongod.service" and "journalctl -xe" for details.

While executing

sudo systemctl start mongod

run journalctl -xe and if the issue is

Failed to start MongoDB Database Server.
-- Subject: Unit mongod.service has failed

Then run sudo mongod --> mongo This will fix the issue and if you want to run with systemctl, then terminate the windows for mongod and mongo and run

sudo systemctl start mongod 

and then mongo

Argon answered 14/6, 2020 at 1:44 Comment(1)
Ran journalctl -xe and guess what? The problem was that the disk was full.Bodyguard
N
6

None of the 30+ existing answers helped me, because my service file was actually missing, not masked or disabled. Re-installing wasn't creating it either for some reason. Solution:

cd /lib/systemd/system
sudo touch mongodb.service
# Copy and paste text to go into service file from snippet below horizontal rule
sudo nano mongodb.service
sudo systemctl daemon-reload
sudo systemctl start mongodb
sudo systemctl status mongodb

[Unit]
Description=An object/document-oriented database
Documentation=man:mongod(1)
After=network.target

[Service]
User=mongodb
Group=mongodb
ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf

[Install]
WantedBy=multi-user.target

You should check that /etc/mongod.conf is actually the location of your conf file, it may be /etc/mongodb.conf instead.

As for how your service file may have gone missing in the first place. I managed to break it by uninstalling 3.0.15, trying and failing to install 5.* due to ubuntu 16 not being able to run it since some dependencies clashed, then re-installing 3.0.15 again.

Nationalist answered 23/3, 2022 at 9:57 Comment(0)
E
5

Just try with this command:

$ sudo systemctl enable mongod
Ealasaid answered 21/4, 2018 at 19:2 Comment(0)
T
5

You can repair

$ sudo rm /var/lib/mongodb/mongod.lock
$ mongod --repair
$ sudo service mongodb start

For Stop

$ sudo service mongodb stop

For Restart-

$ sudo service mongodb restart

For Status-

$ sudo service mongodb status
Tyr answered 30/12, 2019 at 7:59 Comment(0)
P
5

As per documentation:

Run this command to reload the daemon:

sudo systemctl daemon-reload

After this you need to restart the mongod service:

sudo systemctl start mongod

To verify that MongoDB has started, run:

sudo systemctl status mongod

To ensure that MongoDB will start following a system reboot, run:

sudo systemctl enable mongod
Pigsty answered 20/5, 2020 at 11:4 Comment(0)
O
3

May be you are using a wrong version of mongodb list file. I faced this problem but it's my mistake when not selecting the right list file for Ubuntu 16.04. The default selected is for Ubuntu 14.04 and it's the reason for my error: "Failed to start mongod.service: Unit mongod.service not found." enter image description here

Occupation answered 5/11, 2018 at 9:19 Comment(0)
B
3

The following steps helped me solve the problem of not being able to start mongodb on Ubuntu Server 18.04 LTS

Step 1: First, remove MongoDB from previous if installed:

sudo apt remove --autoremove mongodb-org

Step 2: Remove any mongodb repo list files:

sudo rm /etc/apt/sources.list.d/mongodb*.list
sudo apt update

Step 3: Import the public key used by the package management system:

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4

Step 4: Create a list file for MongoDB:

echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.list

Step 5: Reload local package database:

sudo apt-get update

Step 6: Install the MongoDB packages:

sudo apt-get install -y mongodb-org

Step 7: Start MongoDB:

sudo service mongod start

Step 8: Begin using MongoDB:

mongo

Hope it helps you.

Bathelda answered 30/6, 2019 at 17:44 Comment(0)
I
3

In some cases for some security reasons the unit would be marked as masked. This state is much stronger than being disabled in which you cannot even start the service manually.

to check this, run the following command:

    systemctl list-unit-files | grep mongod

if you find out something like this:

    mongod.service                         masked

then you can unmask the unit by:

    sudo systemctl unmask mongod

then you may want to start the service:

    sudo systemctl start mongod

and to enable auto-start during system boot:

    sudo systemctl enable mongod

However if mongodb did not start again or was not masked at all, you have the option to reinstall it this way:

    sudo apt-get --purge mongo*
    sudo apt-get install mongodb-org

thanks to @jehanzeb-malik

Irate answered 16/8, 2019 at 18:30 Comment(1)
I will add precision for those who visit this page in 2021 and above: instead of mongod, use mongodb.Hobnail
S
2

I got the same error for a long while, tried almost all installation isntruciton on google but could not find te answer...

I followed the instructions from https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/ but keep getting the error Failed to start mongod.service: Unit mongod.service not found

I firstly installed using: sudo apt-get install -y mongodb-org Then noticed that wher I run:

$ sudo apt-get install -y mongodb-org
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  mongodb-org-mongos mongodb-org-shell mongodb-org-tools
The following NEW packages will be installed
  mongodb-org mongodb-org-mongos mongodb-org-shell mongodb-org-tools
0 to upgrade, 4 to newly install, 0 to remove and 46 not to upgrade.
Need to get 0 B/40.1 MB of archives.
After this operation, 178 MB of additional disk space will be used.
Selecting previously unselected package mongodb-org-shell.
(Reading database ... 379307 files and directories currently installed.)
Preparing to unpack .../mongodb-org-shell_4.0.3_amd64.deb ...
Unpacking mongodb-org-shell (4.0.3) ...
Selecting previously unselected package mongodb-org-mongos.
Preparing to unpack .../mongodb-org-mongos_4.0.3_amd64.deb ...
Unpacking mongodb-org-mongos (4.0.3) ...
Selecting previously unselected package mongodb-org-tools.
Preparing to unpack .../mongodb-org-tools_4.0.3_amd64.deb ...
Unpacking mongodb-org-tools (4.0.3) ...
Preparing to unpack .../mongodb-org_4.0.3_amd64.deb ...
Unpacking mongodb-org (4.0.3) ...
Setting up mongodb-org-shell (4.0.3) ...
Setting up mongodb-org-mongos (4.0.3) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Setting up mongodb-org-tools (4.0.3) ...
Setting up mongodb-org (4.0.3) ...


$ mongod --version
db version v2.6.12
2018-10-26T12:03:12.362+0200 git version: d73c92b1c85703828b55c2916a5dd4ad46535f6a

The db version was 2.6.12 instead of the latest one 4.0.3. So make sure you dont have mongodb-org-server already installed, if yes, then make sure you uupdate it to your target version (as indicated @https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/ -> Step 4 - Install a specific release of MongoDB.)

target_version = 4.0.3

sudo apt-get install -y mongodb-org=target_version mongodb-org-server=target_version mongodb-org-shell=target_version mongodb-org-mongos=target_version mongodb-org-tools=target_version

$ sudo apt-get install -y mongodb-org=4.0.3 mongodb-org-server=4.0.3 mongodb-org-shell=4.0.3 mongodb-org-mongos=4.0.3 mongodb-org-tools=4.0.3
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed
  mongodb-org mongodb-org-mongos mongodb-org-shell mongodb-org-tools
The following packages will be upgraded:
  mongodb-org-server
1 to upgrade, 4 to newly install, 0 to remove and 45 not to upgrade.
Need to get 15.7 MB/55.8 MB of archives.
After this operation, 217 MB of additional disk space will be used.
Get:1 https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0/multiverse amd64 mongodb-org-server amd64 4.0.3 [15.7 MB]
Fetched 15.7 MB in 2s (6,289 kB/s)                 
Selecting previously unselected package mongodb-org-shell.
(Reading database ... 379306 files and directories currently installed.)
Preparing to unpack .../mongodb-org-shell_4.0.3_amd64.deb ...
Unpacking mongodb-org-shell (4.0.3) ...
**Preparing to unpack .../mongodb-org-server_4.0.3_amd64.deb ...
Failed to stop mongod.service: Unit mongod.service not loaded.
invoke-rc.d: initscript mongod, action "stop" failed.
dpkg: warning: old mongodb-org-server package pre-removal script subprocess returned error exit status 5
dpkg: trying script from the new package instead ...
dpkg: ... it looks like that went OK
Unpacking mongodb-org-server (4.0.3) over (2.6.12) ...**
Selecting previously unselected package mongodb-org-mongos.
Preparing to unpack .../mongodb-org-mongos_4.0.3_amd64.deb ...
Unpacking mongodb-org-mongos (4.0.3) ...
Selecting previously unselected package mongodb-org-tools.
Preparing to unpack .../mongodb-org-tools_4.0.3_amd64.deb ...
Unpacking mongodb-org-tools (4.0.3) ...
Preparing to unpack .../mongodb-org_4.0.3_amd64.deb ...
Unpacking mongodb-org (4.0.3) ...
Processing triggers for ureadahead (0.100.0-20) ...
Setting up mongodb-org-shell (4.0.3) ...
Setting up mongodb-org-mongos (4.0.3) ...
Processing triggers for systemd (237-3ubuntu10.3) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Setting up mongodb-org-tools (4.0.3) ...
Setting up mongodb-org-server (4.0.3) ...
Installing new version of config file /etc/mongod.conf ...
Setting up mongodb-org (4.0.3) ...

and after doing this its all working for me :D

Spathose answered 26/10, 2018 at 10:20 Comment(0)
O
2

Well.... My answer may be considered naive but in fact it has been the only way MongoDB has work in my case, Ubuntu 19.10. I tried to run the commands from the most voted comments and none worked, when running:

mongod --repair

I got this alert:

The first time I used MongoDB that error appeared

With some research I found out that running the DB in another port could be a solution, then:

mongod --port 27018

And it works great for me every time. Long answer but wanted to give context before giving such a simple solution.

(If I'm doing it wrong or doesn't seem logical, plz tell me! Relevant for me)

Overburden answered 24/4, 2020 at 5:28 Comment(0)
H
2

Do not remove your db if you already have some data you found useful. Just run the command below and you're good.

sudo systemctl restart mongodb.service
Hath answered 7/7, 2020 at 0:56 Comment(0)
B
1

To solve the problem of not being able to start mongodb on ubuntu 16.04 1) look at mongodb log file enter image description here

2) we find that the error is due to "Failed to unlink socket file /tmp/mongodb-27017"

3) Look at the permission of file /tmp/mongdb-27017.lock and find that the owner is root instead of mongodb

4) Delete the /tmp/mongodb-27017.sock file manually and use the command "sudo chown mongodb:mongodb /tmp/mongodb*"

5) Start the service with systemcl and use netstat to check whther mongdob has been started on port 27017

enter image description here

Credit: https://www.mkyong.com/mongodb/mongodb-failed-to-unlink-socket-file-tmpmongodb-27017/ https://hevodata.com/blog/install-mongodb-on-ubuntu/

Borghese answered 7/2, 2019 at 3:37 Comment(0)
O
1

I just encountered this on my parrot os and this is how I solved it.

sudo service mongodb start
Omarr answered 6/5, 2019 at 13:37 Comment(0)
D
1

Just follow the below commands. This has worked for me.

  1. Uninstall your mongo completely from your system:

    sudo service mongod stop
    sudo apt-get purge mongodb-org
    sudo rm -r /var/log/mongodb
    sudo rm -r /var/lib/mongodb
    
  2. Now reinstall mongodb using following commands:

    sudo apt update
    sudo apt install -y mongodb**
    

    Note: The database server is automatically started after installation.

  3. Next, let's verify that the server is running and works correctly.

    sudo systemctl status mongodb
    

    You'll see this output:

    mongodb.service - An object/document-oriented database
    Loaded: loaded (/lib/systemd/system/mongodb.service; enabled; vendor preset: enabled)
    Active: active (running) since Sat 2018-05-26 07:48:04 UTC; 2min 17s ago
    Docs: man:mongod(1)
    Main PID: 2312 (mongod)
    Tasks: 23 (limit: 1153)
    CGroup: /system.slice/mongodb.service
       └─2312 /usr/bin/mongod --unixSocketPrefix=/run/mongodb --config /etc/mongodb.conf**
    
Dividend answered 16/7, 2019 at 19:38 Comment(0)
I
1

For those that run into this and end up on this answer, as I did, where they got this error during uninstall orupgrade and Ubuntu keeps failing to uninstall the previous because the service doesn't exist this one line will get you past that and allow the uninstall or upgrade to continue.

sudo touch /lib/systemd/system/mongod.service
Ics answered 29/10, 2019 at 3:23 Comment(0)
F
1

It worked for me on ubuntu 20.04: In my case, mongod.service file was locked so it was giving me the same error. To resolve the issue:- Step 1: Use following command to check if the mongod.service is present there

cd /usr/lib/systemd/system
ls

Step 2: If the file is present there then Run the following command to unlock the file mongod.service

sudo chmod 777 /usr/lib/systemd/system/mongod.service -R

Step 3: Now run the following commands:

sudo systemctl daemon-reload
sudo systemctl start mongod
sudo systemctl enable mongod
Fimbriation answered 30/8, 2020 at 11:11 Comment(0)
H
1

For Ubuntu, if you have old mongodb installed (e.g 3.x).

Then you might need to:

  • Remove old mongodb first.
  • Remove old data, WARNING: this may cause data lose.
    e.g sudo rm -r /var/lib/mongodb
  • Remove init script.
    e.g sudo rm /etc/init.d/mongodb
  • Then re-install new mongodb, (e.g 4.x)
    Refer: https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/
  • Then start with sudo service mongod start.
  • Then check status with sudo service mongod status.

Tips:

  • Don't use sudo service mongodb start, there is an extra b, that's for old mongodb, that's why we do sudo rm /etc/init.d/mongodb.
  • Backup your old data before remove it.
Heeler answered 10/3, 2021 at 2:21 Comment(1)
This is the issue I had. At some point I had installed mongodb the one that came bundled with ubuntu and apparently hadn't removed it completely. That's why my new installation wouldn't start. Removing the old files and reinstalling worked like a charm.Theodore
L
1

This is because Ubuntu or any other OS, won't work proparly for the system files if you have closed rootlogin. That is right. Even when you enter the root on filesystem. I know it seems not logical but it is all about 1 and 0's here.

Even I have su - or ssh [email protected] (random IP, won't expose myself here:))

Still it didn't start!

"Failed to restart mongodb.service: Unit mongodb.service not found."

Then...

You need to activate root login. You can download cyberduck or any file explorer to quickly find the file .

go to: /etc/ssh/

if you couldn't go with a software tool, you can use for the step above: vi /etc/ssh/sshd_config then press ctrl-c write to console for saving it :wq

Change this file called sshd_config: /etc/ssh/sshd_config

Edit to line to yes: PermitRootLogin yes

REBOOT VPS

then write

sudo systemctl restart mongodb

Voila!

if that didn't help either because your VPS initiates services just before on the root, you should reinstall the VPS maybe

Lactary answered 15/5, 2021 at 10:48 Comment(2)
I don't understand how this answers the question, if it's a permission issue then it should give him an error message like: Failed to restart mongod.service: Access denied See system logs and 'systemctl status mongod.service' for details.Polonium
Yes, it is a permission issue or VPS start up issue issuing servicesLactary
S
0

Note that if using the Windows Subsystem for Linux, systemd isn't supported and therefore commands like systemctl won't work:

Failed to connect to bus: No such file or directory

See Blockers for systemd? #994 on GitHub, Microsoft/WSL.

The mongo server can still be started manual via mondgod for development of course.

Sacramentarian answered 3/6, 2018 at 19:21 Comment(0)
T
0

The second step of mongo installation is

echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.4.list

Instead of this command do it manually

  1. cd /etc/apt/
  2. nano sources.list
  3. Write it deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.4 multiverse

And save the file,

Continue all process as in installation docs

It works for me:

Tatyanatau answered 13/8, 2020 at 12:39 Comment(0)
A
0

Try this: sudo systemctl start mongod and to check whether its running use sudo systemctl status mongod

Allethrin answered 20/11, 2020 at 5:18 Comment(0)
S
0

sudo systemctl unmask mongod

The above command worked for me!

sudo service mongod start

Try starting the service it after unmasking it

sudo systemctl status mongod

Check the status using the above command or simply start the mongodb server using mongo command, I hope it works. Cheers

Sulfite answered 17/8, 2021 at 17:35 Comment(0)
S
0

I have Ubuntu 20.04 And i had the same problem.

Finally found a working answer here

sudo dpkg --remove --force-remove-reinstreq mongo-tools
sudo dpkg --remove --force-remove-reinstreq mongodb-server-core

sudo apt-get purge mongodb mongodb-server mongodb-server-core mongodb-clients
sudo apt-get purge mongodb-org
sudo apt-get autoremove

Then reinstall via the official docs.

Though i'd might share. Enjoy.

Stagnate answered 26/9, 2021 at 19:31 Comment(1)
Will this delete the database?Kaftan
T
0

I faced a similar situation of "Failed to start mongod.service: Unit mongod.service not found", followed by "exception in initAndList NonExistentPath: Data directory /data/db not found"

My solution was first to set the path to the config file which had the custom database location instead of "data/db":

mongod --config /etc/mongodb.conf

Then I enabled and started the service with

sudo systemctl enable mongodb.service

Please not that even with mongod, I had to add 'b' because of the version am currently using. But the root daemon stays the same

Thirty answered 25/8, 2022 at 13:53 Comment(0)
S
-1

I got the same error too .. my error is unmet dependencies /var/cache/apt/archives/mongodb-org-server_4.4.2_amd64.deb and I ran this:

sudo dpkg -i --force-all /var/cache/apt/archives/mongodb-org-server_4.4.2_amd64.deb

and it worked

Skit answered 29/12, 2020 at 9:45 Comment(0)
L
-1

Try:

sudo /etc/init.d/mongodb status

or:

sudo /etc/init.d/mongodb start
Lambskin answered 8/7, 2021 at 9:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.