1.mongo的基础命令
db.system.users.find()
use admin
db.auth("root","123456")
##数据库管理员
db.createUser({user:"root",pwd:"123456",roles:[{role:"userAdminAnyDatabase",db:"admin"}]})
##创建库
use dbname
db.createUser({ user: "nf",
pwd: "123456",
roles:[{"role":"readWrite","db":"dbname"},
{"role":"dbAdmin","db":"dbname"},
{"role":"dbOwner","db":"dbname"},
{"role":"read","db":"dbname"}]})
db.createUser({user:'nf2',pwd:'123456',roles:['readWrite']})
############################################
2.mongo的配置文件
systemLog:
destination: file
logAppend: true
path: /home/mongo/log/mongo.log
storage:
dbPath: /home/mongo/data
journal:
enabled: true
processManagement:
fork: true
pidFilePath: /var/run/mongodb/mongod.pid
net:
port: 27017
bindIp: 192.168.1.209
security:
authorization: enabled
转载于:https://blog.51cto.com/wsxxsl/2175902