1use <your database>
2db.createUser({
3 user: '<some username>',
4 pwd: passwordPrompt(),
5 roles: [{
6 role: 'readWrite',
7 db: '<your database>'
8 }]
9})
1use admin
2db.createUser({ user: "mongoadmin" , pwd: "mongoadmin", roles: ["userAdminAnyDatabase", "dbAdminAnyDatabase", "readWriteAnyDatabase"]})
1use admin
2db.createUser(
3 {
4 user: "username",
5 pwd: "password",
6 roles: [ "root" ]
7 }
8 )
9
1use admin
2db.createUser({
3 user: "username",
4 pwd: "password",
5 roles: [ "root" ]
6})