Installing mongoDB issue on ubuntu 20.01

I tried to install mongoDB in my OS so I followed these steps:
1- “wget -qO - https://www.mongodb.org/static/pgp/server-5.0.asc | sudo apt-key add -”
output

pub   rsa4096 2021-02-16 [SC] [expires: 2026-02-15]
      F567 9A22 2C64 7C87 527C  2F8C B00A 0BD1 E2C6 3C11
uid           [ unknown] MongoDB 5.0 Release Signing Key <packaging@mongodb.com>

2- “echo “deb MongoDB Repositories buster/mongodb-org/5.0 main” | sudo tee /etc/apt/sources.list.d/mongodb-org-5.0.list”
output:

deb http://repo.mongodb.org/apt/debian buster/mongodb-org/5.0 main

3- after sudo apt-get update:
“sudo apt install mongodb-org”
output:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
mongodb-org is already the newest version (5.0.2).
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 mongodb-org-database : Depends: mongodb-org-server but it is not going to be installed
                        Depends: mongodb-org-mongos but it is not going to be installed
 mongodb-org-tools : Depends: mongodb-database-tools but it is not going to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

4- “sudo apt --fix-broken install”
output:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following packages were automatically installed and are no longer required:
  libboost-program-options1.71.0 libgoogle-perftools4 libpcrecpp0v5 libtcmalloc-minimal4 libyaml-cpp0.6 mongo-tools mongodb-server-core
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  mongodb-database-tools mongodb-org-mongos mongodb-org-server
The following NEW packages will be installed:
  mongodb-database-tools mongodb-org-mongos mongodb-org-server
0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded.
3 not fully installed or removed.
Need to get 0 B/91.1 MB of archives.
After this operation, 182 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
(Reading database ... 294599 files and directories currently installed.)
Preparing to unpack .../mongodb-org-server_5.0.2_amd64.deb ...
Unpacking mongodb-org-server (5.0.2) ...
dpkg: error processing archive /var/cache/apt/archives/mongodb-org-server_5.0.2_amd64.deb (--unpack):
 trying to overwrite '/usr/bin/mongod', which is also in package mongodb-server-core 1:3.6.9+really3.6.8+90~g8e540c0b6d-0ubuntu5
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Preparing to unpack .../mongodb-org-mongos_5.0.2_amd64.deb ...
Unpacking mongodb-org-mongos (5.0.2) ...
dpkg: error processing archive /var/cache/apt/archives/mongodb-org-mongos_5.0.2_amd64.deb (--unpack):
 trying to overwrite '/usr/bin/mongos', which is also in package mongodb-server-core 1:3.6.9+really3.6.8+90~g8e540c0b6d-0ubuntu5
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Preparing to unpack .../mongodb-database-tools_100.5.0_amd64.deb ...
Unpacking mongodb-database-tools (100.5.0) ...
dpkg: error processing archive /var/cache/apt/archives/mongodb-database-tools_100.5.0_amd64.deb (--unpack):
 trying to overwrite '/usr/bin/bsondump', which is also in package mongo-tools 3.6.3-0ubuntu1
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Errors were encountered while processing:
 /var/cache/apt/archives/mongodb-org-server_5.0.2_amd64.deb
 /var/cache/apt/archives/mongodb-org-mongos_5.0.2_amd64.deb
 /var/cache/apt/archives/mongodb-database-tools_100.5.0_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

Sorry for this long post, but I’m really stuck since 2 days and I didn’t find any solution, plz help me

Hi @Moez_Ben_Rebah

It looks like you have previously install mongodb from the ubuntu repositories which is generating this conflict.
You will have to uninstall those component first. See the following link to the documentation.

Hi chris,
I already do that and now I get this error when I try to check my mongo availability with :

sudo systemctl status mongod

output:

● mongod.service - MongoDB Database Server
     Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Mon 2021-08-23 16:11:02 CET; 18s ago
       Docs: https://docs.mongodb.org/manual
    Process: 4671 ExecStart=/usr/bin/mongod --config /etc/mongod.conf (code=exited, status=14)
   Main PID: 4671 (code=exited, status=14)

أوت 23 16:11:00 desktop systemd[1]: Started MongoDB Database Server.
أوت 23 16:11:02 desktop systemd[1]: mongod.service: Main process exited, code=exited, status=14/n/a
أوت 23 16:11:02 desktop systemd[1]: mongod.service: Failed with result 'exit-code'.

I tried many solution such as:

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

but mongodb still inactive

Hi there,
I fix my issue, by uninstall and reinstall mongoDB

2 Likes

Hi @Moez_Ben_Rebah

Glad you got it installed, that detail is included in the troubleshooting link.

If your output includes a mix of mongodb-org and mongodb binaries, you may need to first apt remove , apt purge , and apt autoremove the mongodb-org package before attempting to remove and purge the Ubuntu mongodb package. After clearing all MongoDB-related packages, retry the installation procedure.

2 Likes

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.