mongodb中走过的那些坑

来源:互联网 发布:微信html5游戏源码 编辑:程序博客网 时间:2024/06/03 17:53

吐槽一下windows的服务器那叫一个难用,抓狂

公司的爬虫需要跑在一台windows的服务器上,mongo本来自然也要装在windows上,想往常一样现在安装,然后问题就来了,只能本地连,于是修改配置文件如下:

# mongodb.conf# Where to store the data.# dbpath=/var/lib/mongodbdbpath=C:\Program Files\MongoDB\Server\3.2\bin\data#where to log#logpath=/var/log/mongodb/mongodb.loglogpath=C:\Program Files\MongoDB\Server\3.2\bin\data\log\mongodb.loglogappend=truebind_ip = 192.168.11.139,localhostport = 27017# Enable journaling, http://www.mongodb.org/display/DOCS/Journalingjournal=true# Enables periodic logging of CPU utilization and I/O wait#cpu = true# Turn on/off security.  Off is currently the default#noauth = trueauth = true# Verbose logging output.#verbose = true
在本地启动mongo,在本地通过客户端进入mongo,创建数据库以后不能创建用户报错如下:

> use adminswitched to db admin> db.createUser({user:"hz", pwd:"hz", roles:[{role:"userAdminAnyDatabase",db:"admin"}]})2016-04-19T18:31:42.712+0800 E QUERY    [thread1] Error: couldn't add user: notauthorized on admin to execute command { createUser: "hz", pwd: "xxx", roles: [{ role: "userAdminAnyDatabase", db: "admin" } ], digestPassword: false, writeConcern: { w: "majority", wtimeout: 30000.0 } } :_getErrorWithCode@src/mongo/shell/utils.js:23:13DB.prototype.createUser@src/mongo/shell/db.js:1230:11@(shell):1:1
这个问题纠结了三天,今天下午看到同事还是不能搞定,我就过去帮忙了,又是一下午过去了,最后忽然想到开了auth认证,然而在本地连mongo的时候没有认证,注释auth,问题果然解决,记录一下,以免以后忘了


0 0