What is the command line to install mongodb?

I am trying to install MongoDB, but I keep getting the following error:

mongodb is not found.

I am using the following install command:

sudo apt-get install mongodb

Solution 1:

You cannot install mongodb using:

apt-get install mongo

You need to execute following command to install mongodb on linux:

sudo apt-get install mongodb-server

Solution 2:

To install mongodb run the commands:

sudo sh -c "echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' >> /etc/apt/sources.list"
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10
sudo apt-get update
sudo apt-get install mongodb-10gen

To test connection (wait at least 15 seconds to let the db start up), run the command below.

mongo

If the command exits with a error about not being able to connect, then reboot, and log back in as the admin user.

Sometimes MongoDB fails to create a network socket when it is started immediately after installation. It should automatically start