How to install MongoDB in Ubuntu14.04

Follow the below steps to install MongoDB in Ubuntu:

1. Import the MongoDB public key
Ubuntu package manager use this key to check the consistency and authenticity of the packages

sudo apt-key adv –keyserver hkp://keyserver.ubuntu.com:80 –recv 7F0CEB10

2. Generate a file with the MongoDB repository url
echo ‘deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen’ | sudo tee /etc/apt/sources.list.d/mongodb.list

3. Refresh the local database with the packages
sudo apt-get update

4. Install the last stable MongoDB version and all the necessary packages on our system
sudo apt-get install mongodb-org

MongoDB installed successfully on the machine, now you can start using of it.

Basic commands and other details:

5. Now, our local MongoDB instance is running, we can check it with
$ ps -ef | grep mongo

6. How can we check the installed version?
$ mongo –version

7. How can we open a MongoDB shell?
$ mongo

8. How to start the mongod service
$ sudo service mongod start

9. How to stop the mongod service
$ sudo service mongod stop

10 . How to restart the mongod service
$ sudo service mongod restart

To Know the directories where MongoDB stores the sources, logs and our data:

Sources: /usr/bin/
Logs: /var/log/mongodb/mongod.log
Data: /var/lib/mongodb/

To install MongoDB by specific version follow the command:
$ apt-get install mongodb-org=2.6.1 mongodb-org-server=2.6.1 mongodb-org-shell=2.6.1 mongodb-org-mongos=2.6.1 mongodb-org-tools=2.6.1

Reference Link: http://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/

 

Permanent link to this article: https://blog.openshell.in/2014/11/how-to-install-mongodb-in-ubuntu14-04/