db.createUser()失败了

时间:2016-05-11 19:51:56

标签: mongodb

我正在尝试在mongoDB数据库中创建一个用户,但每次我输入命令时它只输出...并停止运行。

示例:

> db.createUser({user: "myUser", pwd: "myPassword", roles: [ { role: "readWrite", db: "myDB" } ])
> ...

最后,经过几分钟的等待,我只是输入了几次,它取消了命令。

我在这里做错了什么?

1 个答案:

答案 0 :(得分:1)

错过最终结束}

db.createUser({user: "myUser", pwd: "myPassword", roles: [ { role: "readWrite", db: "myDB" } ]})
                                                                                            ^^^^

更容易看到间距:

db.createUser(
    {
        user: "myUser", 
        pwd: "myPassword", 
        roles: [ 
            { 
                role: "readWrite", 
                db: "myDB" 
            } 
        ]
    }
 )