This section explains, how to install the MongoDB.
- 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
- Install MongoDB, by invoking the command:
yum install -y mongodb-org
- 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" } ] ... } ... )
- Enable authentication in MongoDB, by invoking the command:
vi /etc/mongod.conf security: authorization: enabled
- Restart MongoDB, by invoking command:
service mongod restart