How to install MongoDB on CentOS

 

 

 

 

Document-oriented databases like MongoDB use dynamic schemas to store data in JSON-like documents. In other words, you don’t have to worry about the structure of your database, such as how many fields might there be or the type of fields you might be able to incorporate. As with MongoDB, JSON objects have an equivalent format. 

 

 

 

 

 

Let’s take a look at how to deploy MongoDB on CentOS, Your system must first be updated first.

 

 

 

 

Let’s start,

 

 

 

 

 

 

Install MongoDB Community Edition

 

 

 

 

We use the latest version of MongoDB here. You can adjust this as needed. Use yum to install MongoDB.,

 

 

 

  • Create the /etc/yum.repos.d/mongodb-org-4.4.repo file for MongoDB.
nano /etc/yum.repos.d/mongodb-org-4.4.repo

 

 

  • Paste the following into the editor:

 

[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

 

 

  • Save and exit the file. Next install the latest stable version of MongoDB

 

sudo yum install -y mongodb-org

 

 

 

 

 

Configure MongoDB

 

 

 

 

  • Start MongoDB.
$ systemctl start mongod.service
$ systemctl enable mongod.service

 

 

 

  • Establish a connection to MongoDB by using this command,
mongo

 

 

 

The default security settings in MongoDB are insecure. Check out our guide to secure MongoDB.

 

 

 

 

 

 

 

 

Try VPSie for free today!

 

 

 

Get the most out of learning with VPSie.com