mongod.exe --bind_ip yourIPadress --logpath "C:\data\dbConf\mongodb.log" --logappend --dbpath "C:\data\db" --port yourPortNumber --serviceName "YourServiceName"
--serviceDisplayName "YourServiceName"
--install
mongod --logpath "C:\data\log\log.txt" --logappend --dbpath "C:\data\db"
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"
}
]
}
)