åç
§å®æ¹ç说æï¼ä½¿ç¨db.createUser()æ¹æ³æ·»å ã
db.createUser(user, writeConcern)
Creates a new user for the database where the method runs. db.createUser() returns a duplicate user error if the user already exists on the database.
--------------------------
use products
db.createUser( { "user" : "accountAdmin01",
"pwd": "cleartext password",
"customData" : { employeeId: 12345 },
"roles" : [ { role: "clusterAdmin", db: "admin" },
{ role: "readAnyDatabase", db: "admin" },
"readWrite"
] },
{ w: "majority" , wtimeout: 5000 } )
温馨提示:答案为网友推荐,仅供参考