How To Install and Configure MongoDB NoSQL Database To Linux, Ubuntu, Debian, CentOS, Fedora


SQL is a very powerful language to query, insert, delete, modify data. In recent years the IT industry has developed some alternative ways to store and retrieve data. NoSQL type database servers become very popular. MongoDB is a NoSQL database server to store and retrieve data. In this tutorial, we will look at how to install MongoDB on Linux and distributions like Ubuntu, Debian, CentOS, Fedora, RedHat.

Fedora, CentOS, RedHat

We will use yum or DNF package managers to install MongoDB. Alternatively, we can download the installation package from the MongoDB website.

$ sudo dnf install mongodb-server

Ubuntu, Debian

We will  use apt package manager

$ sudo apt install mongodb-server

Check Service Status

After the installation, we need to start the MongoDB service which is named mongod . The first step is checking the mongod service status.

$ sudo systemctl status mongod.service

As we can see it is stopped.

Start MongoDB Service with Systemctl

Systemctl is de facto and a new tool to manage services in Linux. We will use command systemctl start to start the MongoDB service. We need root privileges to start and stop services.

$ sudo systemctl start mongod.service

Check MongoDB Ports

One of the most occurred problems is a firewall that prevents accessing MongoDB database server ports. We can access with telnet from a remote host like below.

First we will look on MongoDB server which ports are listened. We will use netstat -tl command. MongoDB generally and by default uses port range 27017-27018 .

$ netstat -tln
$ telnet localhost 27017

We can see that we have no problem with network connection. If we get a message like “Connection refused” this means we have a problem with the network connection to the remote host.

LEARN MORE  How To Create Fast Simple Database and Table With Php and Sqlite

Leave a Comment