This section explains, how to install the MongoDB.

  1. Edit the file /etc/yum.repos.d/mongodb-org-4.0.repo with the following content:
    [mongodb-org-4.0]
        name=MongoDB Repository
        baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.0/x86_64/
        gpgcheck=1
        enabled=1
        gpgkey=https://www.mongodb.org/static/pgp/server-4.0.asc
  2. Install MongoDB, by invoking the command:
    yum install -y mongodb-org
  3. Create first user in MongoDB, by invoking the command:
    # Enter into Mongo command-line Shell
        mongo
        # Select admin database inside Mongo shell
    	> use admin;
        # Create first user
    	> db.createUser(
    	...   {
    	...     user: "admin",
    	...     pwd: "changeme",
    	...     roles: [ { role: "root", db: "admin" } ]
    	...   }
    	... )
    
  4. Enable authentication in MongoDB, by invoking the command:
    vi /etc/mongod.conf
        security:
        authorization: enabled
  5. Restart MongoDB, by invoking command:

    service mongod restart