I am trying to install mongodb on my Ubuntu 18.04 LTS, but it has the following error saying
You might want to run \'apt --fix-broken install\' to correct
I had the same problem, and for me the solution was purge, but with the (*) . Purge everything, so i did this:
sudo apt-get purge mongo-tools*
sudo apt-get purge mongodb*
then i follow the steps from the documentation. (Actual version is 4.2.2), and the installation was in Ubuntu 18.04. (URL: https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/)
wget -qO - https://www.mongodb.org/static/pgp/server-4.2.asc | sudo apt-key add -
echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.2.list
sudo apt-get update
sudo apt-get install -y mongodb-org
With that four steps from the documentation i finally install mongodb community edition on Ubuntu. My problem was 3 files,that can't process.
mongodb-org-server
mongodb-org-mongos
mongodb-org-tools
I hope its help someone
run sudo apt autoremove
and re-install mongodb .
Based on this excellent Answer: https://stackoverflow.com/a/51421152/659354
And this Page: https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/
The commands I used to install MongoDB 4.2
sudo apt-get purge mongo*
- Note: mongo to remove the client as well as the server.
sudo apt-get install mongodb-org
- Note: install command run after the Mongodb.org Source was added to the Apt-get sources list.
just want to chime in here. I'm the Senior Technical Writer for MongoDB Server Docs. This post is one of a few that comes up with "install MongoDB on Ubuntu 18.04", and there are several comments here referencing the mongodb
package for installation. The unofficial mongodb
package provided by Ubuntu is not maintained by MongoDB. You should always use the official MongoDB mongodb-org
packages. Furthermore, from a bit of personal testing it looks like having mongodb
installed will cause issues if you try to install mongodb-org
, so its just added trouble
The few times I've run into this issue when testing locally, attempting to install one of the subpackages (i.e. mongodb-org-server
) usually surfaced the actual error (i.e. missing libcurl3
, which was removed in 18.04 as a default installed library). These issues may be more common when testing development builds ( at the time of writing, that's the 4.2 dev series).
To check which package you have installed on your local system, run the following:
sudo apt list --installed | grep mongo
This was my output after I installed mongodb
, then attempted mongodb-org
:
mongo-tools/bionic,now 3.6.3-0ubuntu1 amd64 [installed,auto-removable]
mongodb-org/bionic,now 4.0.5 amd64 [installed]
mongodb-org-shell/bionic,now 4.0.5 amd64 [installed,automatic]
mongodb-server-core/bionic,now 1:3.6.3-0ubuntu1 amd64 [installed,auto-removable]
So you can see, I've got a mix between the two packages (and a bunch of dkpg
errors). I ended up using a mix of apt remove
, apt autoremove
, and apt purge
to fix up the system.
This is because as of now Mongo DB for Ubuntu 18.04 is only available as a development version (See: MongoDB Distros).
I just installed it by doing the following:
Add the corresponding signature:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4B7C549A058F8B6B
Add the supported version:
echo "deb [arch=amd64] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/development multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.list
Update:
sudo apt update
Install:
sudo apt install mongodb-org-unstable
If you get a "GPG error" repeat step 1 with the key that is shown in the error message. You might be able to install via
sudo apt install mongodb
but according to MongoDB this is not supported and will most probably not install the newest version.
cd /etc/apt/sources.list.d
remove files related to mongodb
sudo apt update
This solved it for me.