14

I followed instructions given on the official MongoDB website (https://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/) and I get this error when trying to install MongoDB. How to fix this issue and what's going wrong? Remember I'm using latest Ubuntu version 16.04

sudo apt-get install -y mongodb-org

Reading package lists... Done

Building dependency tree

Reading state information... Done

You might want to run 'apt-get -f install' to correct these:

The following packages have unmet dependencies:

mongodb-org : 

Depends: mongodb-org-shell but it is not going to be installed

Depends: mongodb-org-server but it is not going to be installed

Depends: mongodb-org-mongos but it is not going to be installed

Depends: mongodb-org-tools but it is not going to be installed

virtualbox-5.0 : Depends: libqt4-opengl (>= 4:4.7.2) but it is not going to be installed

Depends: libsdl1.2debian (>= 1.2.11) but it is not going to be installed

Recommends: libsdl-ttf2.0-0 but it is not going to be installed

E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

Edit: Title. MongDB -> MongoDB.

2
12

TL;DR;

Try running this command,

sudo apt-get install libcurl3 openssl

and then

sudo apt-get install mongodb-org

Logs:

So I've followed official instructions on Mongo 4.0 here and got this after running sudo apt-get install mongodb-org

The following packages have unmet dependencies:
 mongodb-org : Depends: mongodb-org-server but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

Then I manually added mongodb-org-server to installation command:

sudo apt-get install mongodb-org mongo-db-server

but then I got

mongodb-org-server : Depends: libcurl3 (>= 7.16.2) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

After manually installing these:

sudo apt-get install libcurl3 openssl

I got it working with single:

sudo apt-get install mongodb-org

command.

1
  • @Arman glad that I could help )
    – naffiq
    Dec 3 '18 at 10:56
10

Install mongodb in Ubuntu 12.04, 14.04 ,16.04

  1. Import the public key used by the package management system

    sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5
    
  2. Create a list file for MongoDB.

    In Ubuntu 12.04 (deprecated):

    echo "deb http://repo.mongodb.org/apt/ubuntu precise/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list
    

    In Ubuntu 14.04:

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

    In 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
    
  3. Reload local package database.

    sudo apt-get update
    

    It will throw a warning

    W: http://repo.mongodb.org/apt/ubuntu/dists/trusty/mongodb-org/3.0/Release.gpg: Signature by key 492EAFE8CD016A07919F1D2B9ECBEC467F0CEB10 uses weak digest algorithm (SHA1)
    

    Just Ignore It.

  4. Install the MongoDB packages.

    sudo apt-get install -y mongodb-org
    

After installation you can start MongoDB using

sudo service mongod start

To stop MongoDB use

sudo service mongod stop

To restart MongoDB use

sudo service mongod restart

If that didn't work, check here to see if any of the steps have been updated: https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/

2
  • 3
    you are not using latest mongo 3.4 as referenced in OP mongo link Jan 9 '17 at 19:32
  • Thank you for this answer!
    – DuDoff
    Dec 4 '19 at 12:07
2

I tried running the install instructions posted by t9toqwerty / muru. But still got the message

the following packages have unmet dependencies:

What worked for me was to manually install MongoDB from the tarball. Original link is: https://docs.mongodb.com/manual/tutorial/install-mongodb-on-linux/

1) Download Binaries

curl -O https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.4.9.tgz

2) Extract Files

tar -zxvf mongodb-linux-x86_64-3.4.9.tgz

3) Copy Archive to Target Directory

mkdir -p mongodb
cp -R -n mongodb-linux-x86_64-3.4.9/ mongodb

4) Place location in the PATH variable.

export PATH=<mongodb-install-directory>/bin:$PATH

(Replace <mongodb-install-directory> with the path to the extracted MongoDB archive. For me this was /home/myusername/mongodb/mongodb-linux-x86_64-3.4.9)

Next comes running it:

1) Create Data Directory

mkdir -p /data/db

2) Set Permissions

This is making sure the user has read and write permissions for the directory. Find the directory in the terminal, and enter

chmod 777 /data/db

3) Run it!

mongod

If you didn't set up the PATH variable in step 4, run mongo by entering the path to your bin file— like so

<path to binary>/mongod
2

First, remove all mongo packages.

  1. List all mongo packages.

sudo apt list --installed | grep 'mongo'

  1. Remove package.

sudo apt-get purge --auto-remove packagename

  1. Then follow the mongo installation documentation.

https://docs.mongodb.com/manual/tutorial/install-mongodb-on-linux/

0

Xenial (Ubuntu 16.04); MongoDB v. 3.2.11

apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927
echo "deb http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.2 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-3.2.list
apt-get -qq update   (if you are using docker)
apt-get update
apt-get install mongodb-org

I just did it and it was fine.

Font: https://www.digitalocean.com/community/tutorials/how-to-install-mongodb-on-ubuntu-16-04

1
  • I guess the OP is trying to install mongodb 3.6 since I had same issues when installing that version. So installing version 3.2 might not be an acceptable solution. Feb 8 '18 at 14:42
0

I faced the same couple of days back. Try running through aptitude. This will take care of installing all the dependency packages.

sudo apt-get install aptitude
sudo aptitude install mongodb-org
0

I was on Ubuntu 18 (bionic) and accidentally added Ubuntu 20 repo of mongo to my repo list. I had to remove it using the (-r) parameter.

sudo add-apt-repository -r 'deb [arch=amd64] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 multiverse'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.