How to guides and technology tutorials for Amazon AWS, Google Cloud, Linux, macOS, Windows, and other systems

How to install MongoDB on CentOS

Published: 05 March 2017
Filed Under: CentOS

MongoDB is an document-based NoSQL database. It provides high performance, high availability, and scaling. Data is stored as a document record made up of JSON objects.

Add the MongoDB repo

Create a new file called /etc/yum.repos.d/mongodb-org-4.2.repo and add the following text to it.

name=MongoDB Repository

Install MongoDB

Run the following commands to install MongoDB and add an exception to SELinux to allow it to run with its default configuration.

sudo yum update
sudo yum install mongodb-org
sudo semanage port -a -t mongod_port_t -p tcp 27017

Start MongoDB

Start MongoDB and set it to automatically start when the system boots.

sudo systemctl start mongod
sudo systemctl enable mongod