mongod.exe --bind_ip yourIPadress --logpath "C:datadbConfmongodb.log" --logappend --dbpath "C:datadb" --port yourPortNumber --serviceName "YourServiceName"
--serviceDisplayName "YourServiceName"
--install
mongod --logpath "C:dataloglog.txt" --logappend --dbpath "C:datadb"
1,
use admin
db.createUser(
{
user: "admin",
pwd: "admin",
roles: [ { role: "userAdminAnyDatabase", db: "admin" } ]
}
)
2,
use demo
db.createUser(
{
user:"ybl",
pwd:"926055",
roles:[{"role":"readWrite","db":"demo"}]
}
)
3,
use admin db.auth("admin","admin") - - 用户管理
use demo db.auth("ybl","926055") - - 读写
use demo db.auth("hqw","940331") - - 只读
use admin
db.createUser(
{
user: "adminUserName",
pwd: "userPassword",
roles:
[
{
role: "userAdminAnyDatabase",
db: "admin"
}
]
}
)