Installing MongoDB Community Edition on Ubuntu 14.04
Feb 18, 2016
This post is more than 5 years old. While math doesn't age, code and operating systems do. Please use the code/ideas with caution and expect some issues due to the age of the content. I am keeping these posts up for archival purposes because I still find them useful for reference, even when they are out of date!
In this post I'll cover installing the Community Edition of MongoDB on Ubuntu 14.04 in a way that lets me use more recent versions of MongoDB than are available using the standard :code:`$ sudo apt-get install`. If that sounds interesting, follow along.
To do this, I will use the instructions provided at the MongoDB site: Install MongoDB Community Edition -- you should check to see if there are more recent, or different, instructions before you proceed! At the time I installed, the process was to first get the MongoDB public GPG key:
$ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927
Next, we create a list file that tells Ubuntu where the repositories are located-- this location depends on the version of Ubuntu being used. For Ubuntu 14.04, the file is created using:
$ echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list
Now, if you try:
$ ls /etc/apt/sources.list.d/
you should see
Finally, the install commands are:
$ sudo apt-get update
$ sudo apt-get install -y mongodb-org
The Mongo server can be started, stopped, etc using the typical commands for
this type of service. To start, use (notice the service is called
$ sudo service mongod start
start: Job is already running: mongod
You should get an "already running" message if all went well above. You can also check the status using:
$ sudo service mongod status
mongod start/running, process 15373
and, stop is (as you might expect):
$ sudo service mongod stop
That's it! Now, checkout the MongoDB docs for learning more about Mongo. As always, questions, corrections and comments are welcome-- just be nice!