首先 use admin
db.createUser({user: 'xiaoba',pwd: '169169', roles: [{role: 'root', db: 'admin'}]})
上面方法不行,就用下面这种
db.addUser('mongodb','123456');
首先 use admin
db.createUser({user: 'xiaoba',pwd: '169169', roles: [{role: 'root', db: 'admin'}]})
上面方法不行,就用下面这种
db.addUser('mongodb','123456');