Month: October 2019

MongoDB on RedHat/CentOS/Fedora

INSTALLATION OF CENTOS

Add the additionnal following repo to get the mongoDB package not included by default:

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

ADDING ADMIN USER

  • mongo
  • use admin
db.createUser({
       user: "username",
       pwd: "password",
       roles: [ "root" ]
   }
)

TESTING

  • mongo -u username -p password

ACCESS MONGODB FROM INTERNET

  • sudo nano /etc/mongod.conf

Change 127.0.0.1 (localhost) to 0.0.0.0 (all IP):

#bindIp: 127.0.0.1 
bindIp: 0.0.0.0

Restart the mongod service using this command:

  • sudo service mongod restart

USING A MONGODB TOOL GUI

You can use several tools to access and manage your mongoDB database. I recommend using the following tools: