Installation of Mongo in centos7 and related configuration

Time:2021-3-22
  1. Install mongodb

~ yum -y install mongodb-org

  1. View installation location

~ whereis mongod

Installation of Mongo in centos7 and related configuration

  1. ‘/ etc’/ mongod.conf ’Allow Internet access and enable the authentication mode “security” and change the data document storage path.

Installation of Mongo in centos7 and related configuration

  1. Start Mongo, check the Mongo status, and running is successful.

~ systemctl start mongod.service
~ systemctl status mongod.service

Installation of Mongo in centos7 and related configuration

The documents saved by Mongo are also transferred.

Installation of Mongo in centos7 and related configuration

  1. Go to Mongo

~ mongo
Installation of Mongo in centos7 and related configuration

Step 2: switch to the admin database
~ use admin

Step 3: create an administrator account
~ db.createUser({user:”root”,pwd:”123456″,roles:[“root”]})

  1. View Mongo database

~ show dbs
After the security verification is configured, the show DBS may report an error

Installation of Mongo in centos7 and related configuration
The solution is as follows: enter the Mongo user directory, log in and verify, and return 1
~ use admin
~ db.auth(“wuzeon”,”xxxxxx”)

Installation of Mongo in centos7 and related configuration