How to install Mongodb in CentOS?

MongoDB is a Free and open-source cross-platform document-oriented database program. Classified as a NoSQL database program, MongoDB avoids the traditional table-based relational database structure in favor of JSON-like documents with dynamic schemas, making the integration of data in certain types of applications easier and faster.

  1. Login into your VPS via ssh

  2. Create mongodb repository file using an editor as below.

    nano /etc/yum.repos.d/mongodb.repo

    Mongodb Respitory

  3. If you are running a 64-bit system, add the below information to the file you have created.

    [mongodb]

    name=MongoDB Repository

    baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/

    gpgcheck=0

    enabled=1

    For 64 Bit System

  4. Press CTRL+x to exit and press Y to save the file as per screenshot.

    Save File

  5. It will ask to confirm filename and path. Just press enter.

    File Saved

  6. As a best practice, we should also update our package using below command.

    yum -y update

  7. Now, run below command to install MongoDB.

    yum -y install mongodb-org mongodb-org-server


That's it. MongoDB is installed. Below are some useful commands.

  • Start-Up MongoDB - systemctl start mongod

  • Check MongoDB Service Status - systemctl status mongod

  • Enter the MongoDB Command Line - mongo

  • Shutdown MongoDB - systemctl stop mongod

  • Summary List of Status Statistics (Continuous) - mongostat

  • Summary List of Status Statistics (5 Rows, Summarized Every 2 Seconds) - mongostat --rowcount 5 2

  • By default MongoDB server listening on port 27017 on the localhost interface.To change mongodb listening port to 22222 :: mongo --port 22222


  • 0 Users Found This Useful

Was this answer helpful?


Related Articles

Will internal traffic between two VPS viz. a Database Server and a Web Server be counted in my bandwidth usage?

Yes it will. The traffic will be counted in the bandwidth usage of your VPS. Even if you use...

Can I open APN port 2195 on my VPS?

You will get full administrative control of your VPS, therefore you can surely open/close any...

Fix :: Linux SSH error "connection refused"

Problem Statement Can't connect to a Linux server(Debian Flavour) via SSH. Error Message...

Do You Offer VPS with 8 vCPU Cores?

No, we do not provide VPS with 8 vCPU cores. We provide VPS with maximum 4 vCPU cores. This is...

Do You Provide TUN/TAP On VPS Hosting?

Typically, TUN/TAP is used when you want to utilize VPN services from your VPS. Windows VPS...