How to Install MongoDB Server on Centos 7

centos-mongo

MongoDB is a free and open-source cross-platform document-oriented database program. MongoDB is a NoSQL database program and uses JSON-like documents with schemas. MongoDB supports many NoSQL database types.

  • Document databases
  • Graph stores
  • Key-value stores
  • Wide-column stores

To know more about MongoDB visit www.mongodb.com

In this article we will learn how to install MondoDB server on Centos machine.

Step 1. Login into your Linux Machine.

Step 2. Add the repository of MongoDB in the yum server.

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

Step 3. Install MongoDB Server by using below command.

# yum install mongodb-org -y

Step 4. Start MongoDB Server.

# service mongod start

Step 5. Open MongoDB Shell by using below command.

# mongo

Step 6. Create & switch into a new database.

> use employee

Step 7. Create a new root user named myuser.

 > db.createUser(
   {
     user: "myuser",
     pwd: "1234",
     roles: ["readWrite", "dbAdmin"] 
} );

user-creation-page-pic

Step 8. Execute below command to view Users list.

> db.getUsers()

view-users