1: Installation
Mkdir-p/app/mongodb
Tar zxvf mongodb-linux-x86_64-rhel62-3.4.6.tgz
VI. bash_profile
Path= $PATH: $HOME/bin
Path= $PATH:/app/mongodb/mongodb-linux-x86_64-rhel62-3.4.5/bin
Export PATH
--Let the configuration file take effect
source. bash_profile
--Create mongo.conf under the/app/mongodb directory
Dbpath=/app/mongodb/data
Logpath=/app/mongodb/logs/mongo.log
Logappend=true
Journal=true
Quiet=true
port=7979
Fork=true
--Create a directory
/app/mongodb/data
--Create a log file
/app/mongodb/logs/mongo.log
2: Create DATABASE and authorization information
$ MONGO127.0.0.1:7979>Use gwzhswitched to DB test> Db.createuser ({User:"Test",pwd:"Test", Roles:[{role:"ReadWrite"Db:"Test"}]}) Successfully added User: {"User":"Test", "Roles" : [ { "role":"ReadWrite", "DB":"Test" } ]}>
3: Start in licensing mode
Mongod--config mongodb/mongo.conf--auth
4: Authorized Authentication Login
$ MONGO 127.0.0.1:7979
MongoDB Shell version v3.4.6
Connecting to:mongodb://127.0.0.1:7979
MongoDB Server version:3.4.6
> Use test
Switched to DB test
> Db.auth (' Test ', ' test ')
1
>
CentOS under Installation configuration MongoDB