How to Install MongoDB 4.x on CentOS

How to Install MongoDB 4.x on CentOS

December 10, 2019

MongoDB is a popular NoSQL database system that provides scalability, high performance, and availability. In this step-by-step guide, we’ll walk through the installation process for MongoDB 4.x Community Edition on CentOS.

Prerequisites

Before you begin, ensure that you have the following prerequisites:

  • A CentOS system (version 7 or 8)
  • Administrative privileges (you can use sudo)

MongoDB

Installation Steps

1. Configure the Package Management System (yum)

Create a file named /etc/yum.repos.d/mongodb-org-4.4.repo to set up the MongoDB repository for installation using yum. You can use the following command to create the file:

sudo vi /etc/yum.repos.d/mongodb-org-4.4.repo

Add the following content to the file:

[mongodb-org-4.4]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.4/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-4.4.asc

2. Install MongoDB Packages

Open a terminal and run the following command to install the latest stable version of MongoDB:

sudo yum install -y mongodb-org

Alternatively, if you want to install a specific release of MongoDB, specify each component package individually and append the version number to the package name. For example:

sudo yum install -y mongodb-org-4.4.29 mongodb-org-server-4.4.29 mongodb-org-shell-4.4.29 mongodb-org-mongos-4.4.29 mongodb-org-tools-4.4.29

3. Start MongoDB Service

After installation, start the MongoDB service using the following command:

sudo systemctl start mongod

4. Enable MongoDB to Launch on Boot

To ensure MongoDB starts automatically when your system boots up, enable it with:

sudo systemctl enable mongod

5. Access MongoDB Shell

To interact with MongoDB, open the MongoDB shell by entering:

mongo

Conclusion

You’ve successfully installed MongoDB on CentOS! Feel free to explore its features and start building your applications. Remember to check the official MongoDB documentation for any additional details or troubleshooting tips. Happy coding! 🚀🌟

Congratulations! You have successfully installed MongoDB server on your system. For practice, you may use the MongoDB browser shell.

References:
http://docs.mongodb.org/manual/installation/

Leave A Comment

ZiniSoft

Hello! We are a group of skilled developers and programmers.

Hello! We are a group of skilled developers and programmers.

We have experience in working with different platforms, systems, and devices to create products that are compatible and accessible.