1

I cannot install MongoDB on my Linux Mint.

Operating System: Linux Mint 19.1

Kernel: Linux 4.15.0-50-generic

Architecture: x86-64

I followed official documentation.

Import the public key used by the package management system

$ wget -qO - https://www.mongodb.org/static/pgp/server-4.0.asc | sudo apt-key add -

Create a list file for MongoDB Ubuntu 18.04 (Bionic)

$ 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

Reload local package

$ sudo apt-get update

Install the MongoDB package

$ sudo apt-get install -y mongodb-org

While installing got these errors:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  icoutils libboost-program-options1.65.1 libgoogle-perftools4 libpcrecpp0v5
  libtcmalloc-minimal4 libwine-development libwxgtk3.0-gtk3-0v5
  libyaml-cpp0.5v5 mongodb-server-core python-wxgtk3.0 python-wxversion
  wine64-development
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  mongodb-org-mongos mongodb-org-server mongodb-org-shell mongodb-org-tools
The following NEW packages will be installed:
  mongodb-org mongodb-org-mongos mongodb-org-server mongodb-org-shell
  mongodb-org-tools
0 upgraded, 5 newly installed, 0 to remove and 245 not upgraded.
Need to get 48.3 MB/73.0 MB of archives.
After this operation, 267 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-shell amd64 4.0.12 [9,865 kB]
Get:2 https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0/multiverse amd64 mongodb-org-tools amd64 4.0.12 [38.5 MB]
Get:3 https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0/multiverse amd64 mongodb-org amd64 4.0.12 [3,528 B]
Fetched 48.3 MB in 31s (1,553 kB/s)                                            
Selecting previously unselected package mongodb-org-shell.
(Reading database ... 349983 files and directories currently installed.)
Preparing to unpack .../mongodb-org-shell_4.0.12_amd64.deb ...
Unpacking mongodb-org-shell (4.0.12) ...
Preparing to unpack .../mongodb-org-server_4.0.12_amd64.deb ...
Unpacking mongodb-org-server (4.0.12) ...
dpkg: error processing archive /var/cache/apt/archives/mongodb-org-server_4.0.12_amd64.deb (--unpack):
 trying to overwrite '/usr/bin/mongod', which is also in package mongodb-server-core 1:3.6.3-0ubuntu1.1
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Preparing to unpack .../mongodb-org-mongos_4.0.12_amd64.deb ...
Unpacking mongodb-org-mongos (4.0.12) ...
dpkg: error processing archive /var/cache/apt/archives/mongodb-org-mongos_4.0.12_amd64.deb (--unpack):
 trying to overwrite '/usr/bin/mongos', which is also in package mongodb-server-core 1:3.6.3-0ubuntu1.1
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Selecting previously unselected package mongodb-org-tools.
Preparing to unpack .../mongodb-org-tools_4.0.12_amd64.deb ...
Unpacking mongodb-org-tools (4.0.12) ...
Selecting previously unselected package mongodb-org.
Preparing to unpack .../mongodb-org_4.0.12_amd64.deb ...
Unpacking mongodb-org (4.0.12) ...
Errors were encountered while processing:
 /var/cache/apt/archives/mongodb-org-server_4.0.12_amd64.deb
 /var/cache/apt/archives/mongodb-org-mongos_4.0.12_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

Tried to start the DB

$ sudo service mongod start

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

The command below gives the same error:

sudo apt-get install -f

Unable to remove mongodb-server-core:

$ apt remove mongodb-server-core

Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 mongodb-org : Depends: mongodb-org-server but it is not going to be installed
               Depends: mongodb-org-mongos but it is not going to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
7
  • What is the source of the mongodb-server-core listed in the "no longer required" section of the output? Commented Aug 11, 2019 at 17:17
  • Not sure, but it seems like you have an older version already installed: dpkg: error processing archive /var/cache/apt/archives/mongodb-org-server_4.0.12_amd64.deb (--unpack): trying to overwrite '/usr/bin/mongod', which is also in package mongodb-server-core 1:3.6.3-0ubuntu1.1 You could try apt remove mongodb-server-core (To remove the old version). You should be able to test the old version by running /usr/bin/mongod. You may not have a service file for that, that may be why it isn't starting now (the old version). Commented Aug 11, 2019 at 19:53
  • @rudib I tried to remove mongodb-server-core but it says that "You might want to run 'apt --fix-broken install' to correct these. The following packages have unmet dependencies,.... Same as previous error Commented Aug 11, 2019 at 20:29
  • I see. Could you update your post with the full info? Commented Aug 11, 2019 at 20:32
  • @rudib info updated Commented Aug 12, 2019 at 2:25

3 Answers 3

0

There is conflict with mongodb-server-core Try to

sudo apt-get purge mongod*
sudo apt-get update

and re-install

0

Had the same issue. Nothing I found online worked. But eventually guessed a solution that did.

Instead of

sudo apt-get purge mongod*

I did

sudo apt-get purge mongo*

then problem solved.

0

Same issue was me on Ubuntu machine.

sudo apt-get purge mongod*
sudo apt autoremove
sudo apt-get update && sudo apt-get upgrade

The above commands help.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.