mongo添加新的数据库并为新数据库添加可读可写的用户
> show databases;
admin 0.000GB
config 0.000GB
local 0.000GB
plante 0.000GB
test01 0.000GB
test02 0.001GB
> use longyan
switched to db longyan
> db.longyan.insert({"name":"test"})
WriteResult({ "nInserted" : 1 })
> show databases
admin 0.000GB
config 0.000GB
local 0.000GB
longyan 0.000GB
plante 0.000GB
test01 0.000GB
test02 0.001GB
> use longyan
switched to db longyan
>
db.createUser(
{
user: "用户名",
pwd: "密码",
roles: [ "readWrite" ]
}
);