MongoDB Add user in v3.0 Problem Resolution (property ' AddUser ' of object Admin was not a func) #
problem: An error occurred while creating a MongoDB account> Db.adduser (' Jyu ', ' aerohive ') 2015-08-05t20:03:02.767+0800 E QUERY typeerror:property ' addUser ' of object admin is not a function
#步骤1:At first, I thought it was a privilege problem to restart MongoDB Mongod--dbpath=/opt/mongodb/data in a non-auth manner--logpath=/opt/mongodb/logs/mongodb.log-port=27017 --fork (Note: Auth is required, the start command is: Mongod--dbpath=/opt/mongodb/data--logpath=/opt/mongodb/logs/mongodb.log--auth--port= 27017--fork)
#步骤2:Still prompt error, and then find the reason, originally V3 version MongoDB has no longer use adduser, but adopted the Db.createuser
#最终解决方案:Use this method to increase the user's reference: http://docs.mongodb.org/manual/reference/method/db.createUser/#create-administrative-user-with-roles
Db.createuser (
{
User: "Accountuser",
pwd: "Password",
roles: ["ReadWrite", "DbAdmin"]
}
)
#