Installing MongoDB on Redhat Linux

A detailed tutorial on how to install MongoDB version 3.2 on Redhat Linux


The following notes describe how I installed the latest MongoDB server (version 3.2 as of writing), on my laptop running Fedora 23. The steps described will also work on CentOS or RHEL, with the only difference being the use of the dnf command on Fedora: you should use the yum command instead on older Redhat systems. Note that all of the commands are run with root privileges.


The MongoDB version in the official Fedora 23 repo is too old (3.0.9-1), so we will configure official repo from MongoDB for their community edition. Firstly import the repo key:

$ rpm --import

Now create a new repo config file:

$ nano /etc/yum.repos.d/mongodb-org-3.2.repo

...with the following content:

name=MongoDB Repository

Now to install, use yum or dnf:

$ dnf install -y mongodb-org

Before starting, you should ensure that SELinux is disabled:

$ nano /etc/selinux/config



Now let's start the MongoDB service:

$ service mongod start
Starting mongod (via systemctl):                           [  OK  ]

If you want MongoDB to start when the machine starts, you can run the following:

$ chkconfig mongod on

Now to login to MongoDB to verify it's running, simply use the mongo command:

$ mongo
MongoDB shell version: 3.2.4
connecting to: test
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
Questions? Try the support group

Have fun!

John Collins

I have been writing about web technology and software development since 2001. I am the developer of the Alpha Framework for PHP, and the personal productivity app. I love open source, technology, and economics.