mongoDB add user in v3.0 问题的解决(Property 'addUser' of object admin is not a func)
2016-10-20 13:57
537 查看
mongoDB add user in v3.0 问题的解决(Property 'addUser' of object admin is not a func)
#
问题:创建mongodb帐户时,出错
> db.addUser('jyu', 'aerohive')
2015-08-05T20:03:02.767+0800 E QUERY TypeError: Property 'addUser' of object admin is not a function
#步骤1:
刚开始以为是权限问题,以非auth方式重启mongodb
mongod --dbpath=/opt/mongodb/data --logpath=/opt/mongodb/logs/MongoDB.log -port=27017 --fork
(注:需要auth的,启动命令为:
mongod --dbpath=/opt/mongodb/data --logpath=/opt/mongodb/logs/MongoDB.log --auth --port=27017 --fork)
#步骤2:
仍然提示出错,然后查找到原因,原来是V3版本mongoDB已经不再使用addUser,而是采用了db.createUser
#最终解决方案:
采用以下这种方式增加用户
参考:http://docs.mongodb.org/manual/reference/method/db.createUser/#create-administrative-user-with-roles
#
问题:创建mongodb帐户时,出错
> db.addUser('jyu', 'aerohive')
2015-08-05T20:03:02.767+0800 E QUERY TypeError: Property 'addUser' of object admin is not a function
#步骤1:
刚开始以为是权限问题,以非auth方式重启mongodb
mongod --dbpath=/opt/mongodb/data --logpath=/opt/mongodb/logs/MongoDB.log -port=27017 --fork
(注:需要auth的,启动命令为:
mongod --dbpath=/opt/mongodb/data --logpath=/opt/mongodb/logs/MongoDB.log --auth --port=27017 --fork)
#步骤2:
仍然提示出错,然后查找到原因,原来是V3版本mongoDB已经不再使用addUser,而是采用了db.createUser
#最终解决方案:
采用以下这种方式增加用户
参考:http://docs.mongodb.org/manual/reference/method/db.createUser/#create-administrative-user-with-roles
db.createUser( { user: "accountUser", pwd: "password", roles: [ "readWrite", "dbAdmin" ] } )
#
相关文章推荐
- mongoDB add user in v3.0 问题的解决(Property 'addUser' of object admin is not a func)
- mongoDB add user in v3.0 问题的解决(Property 'addUser' of object admin is not a func)
- mongoDB add user in v3.0 问题的解决(Property 'addUser' of object admin is not a func)
- 彻底解决:@synthesize of 'weak' property is only allowed in ARC or GC mode :问题
- Unable to add module to the current project as it is not of packaging type 'pom' 问题解决
- 解决此类问题:warning: unable to bind to property '' on class 'Object' (class is not an IEventDispatcher) .
- centos username is not in the sudoers file 问题解决方法
- It is not possible to run two different versions of ASP.NET in the same IIS process.问题的解决
- QT中的 'rand' is not a member of 'std'问题的解决
- The problem of the user is not associated with a trusted sql server connection 混合登录选项设置的问题
- Oralce监听服务出现问题解决方案 (ORA-12505, TNS:listener does not currently know of SID given in connect)
- The hierarchy of the type is inconsistent 问题解决
- Operation is not valid due to the current state of object 错误解决
- Ubuntu_Usernameis not in the sudoers file解决方法
- 错误解决:Unable to add module to the current project as it is not of packagi
- bios in this system is not fully ACPI compliant 问题的解决
- 【QA4】【sudoers问题解决】(*** is not in the sudoers file.This incident will be reported)
- 解决is not in the sudoers file问题
- error LNK2011: precompiled object not linked in; image may not run 问题解决方法
- 解决HttpContext.User.IsInRole() 永远返回false的问题