How to Install MongoDB on Ubuntu 14.04 and 15.04
As we all know that MongoDB is becoming a default choice for certain part of community and is also emphasized as M in MEAN stack. Its an open source NoSQL database that is available free of cost and that you can make use of. In this article I will show you to quickly utilize official MongoDB repository to get and install most recent version of MongoDB.
Prerequisites
You will need a running Ubuntu 14.04 server and a sudo non-root user, A great article on setting up such account can be found here
What you need to do
By default, MongoDB package is included in official Ubuntu package repositories, but this does not guarantee that its the latest version, so a better and recommended way to install MongoDB is to Import the MongoDB public GPG key used by the package management system.
1 |
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10 |
Once you are done with above command you will see something like this
1 2 3 |
gpg: Total number processed: 1 gpg: imported: 1 (RSA: 1) |
Next
Let’s add Mongo repository details to APT, this is required so you have apt
remember where to find MongoDB the next time you want to update it.
Use the commands below
1 |
echo "deb http://repo.mongodb.org/apt/ubuntu "$(lsb_release -sc)"/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list |
Let’s now update the package list by using the command below
1 |
sudo apt-get update |
Next
We install MongoDB by issuing the command below
1 |
sudo apt-get install -y mongodb-org |
When installation finish, you now have a MongoDB server, Mongo shell, and other Mongo tools such as mongoimport
, mongodump
etc
You can now verify if MongoDB server s running by issuing the following command
1 2 3 |
> service mongod status ## Ouput of above command will look something like this mongod start/running, process 7456 |
Helpful commands
- Stops mongo
sudo service mongod stop
- Start mongo
sudo service mongod start
- Restart mongo
sudo service mongod restart
You can read more on official Mongo docs website
http://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/
I hope this helps
Cheers.
A workaround can be found here
https://jira.mongodb.org/browse/SERVER-17742
Running an Ubuntu server 15.04 in a VM, the apt-get update command can’t find the repositories:
W: Failed to fetch http://repo.mongodb.org/apt/ubuntu/dists/vivid/mongodb-org/3.0/multiverse/binary-amd64/Packages 404 Not Found
W: Failed to fetch http://repo.mongodb.org/apt/ubuntu/dists/vivid/mongodb-org/3.0/multiverse/binary-i386/Packages 404 Not Found