2

使用参数保护 mongo 后--auth,我收到以下错误消息:

MongoError: 未在 mocha 上授权执行命令 { listIndexes: "users", cursor: {} }

mongo 在我的本地机器上的默认端口localhost:27017。google 和 stackexchange 搜索没有发现任何类似的东西,因此我们将不胜感激。

大概我需要做的就是授权给“mocha”数据库上的用户。用户是谁?

完整的堆栈跟踪:

W20150822-22:58:09.173(1)? (STDERR) 

/Users/malcolm/.meteor/packages/velocity_meteor-tool/.1.1.3_2.1uk1vnq++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:278
W20150822-22:58:09.173(1)? (STDERR)                         throw(ex);
W20150822-22:58:09.173(1)? (STDERR)                               ^
W20150822-22:58:09.214(1)? (STDERR) MongoError: not authorized on mocha to execute command { listIndexes: "users", cursor: {} }
W20150822-22:58:09.214(1)? (STDERR)     at Object.Future.wait (/Users/malcolm/.meteor/packages/velocity_meteor-tool/.1.1.3_2.1uk1vnq++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:398:15)
W20150822-22:58:09.214(1)? (STDERR)     at [object Object].MongoConnection._ensureIndex (packages/mongo/mongo_driver.js:733:1)
W20150822-22:58:09.214(1)? (STDERR)     at [object Object].Mongo.Collection._ensureIndex (packages/mongo/collection.js:620:1)
W20150822-22:58:09.215(1)? (STDERR)     at Accounts.urls (packages/accounts-base/accounts_server.js:1309:1)
W20150822-22:58:09.215(1)? (STDERR)     at /private/var/folders/3n/2yry_ys510q6dx0frpznpc4c0000z_/T/meteor-test-run15cht13/.meteor/local/build/programs/server/packages/accounts-base.js:1616:4
W20150822-22:58:09.215(1)? (STDERR)     at /private/var/folders/3n/2yry_ys510q6dx0frpznpc4c0000z_/T/meteor-test-run15cht13/.meteor/local/build/programs/server/packages/accounts-base.js:1659:3
W20150822-22:58:09.215(1)? (STDERR)     at /private/var/folders/3n/2yry_ys510q6dx0frpznpc4c0000z_/T/meteor-test-run15cht13/.meteor/local/build/programs/server/boot.js:222:10
W20150822-22:58:09.215(1)? (STDERR)     at Array.forEach (native)
W20150822-22:58:09.215(1)? (STDERR)     at Function._.each._.forEach (/Users/malcolm/.meteor/packages/velocity_meteor-tool/.1.1.3_2.1uk1vnq++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/underscore/underscore.js:79:11)
W20150822-22:58:09.215(1)? (STDERR)     at /private/var/folders/3n/2yry_ys510q6dx0frpznpc4c0000z_/T/meteor-test-run15cht13/.meteor/local/build/programs/server/boot.js:117:5
W20150822-22:58:09.215(1)? (STDERR)     - - - - -
W20150822-22:58:09.216(1)? (STDERR)     at Object.toError (/Users/malcolm/.meteor/packages/mongo/.1.1.0.1ruc6ua++os+web.browser+web.cordova/npm/node_modules/mongodb/lib/mongodb/utils.js:114:11)
W20150822-22:58:09.216(1)? (STDERR)     at /Users/malcolm/.meteor/packages/mongo/.1.1.0.1ruc6ua++os+web.browser+web.cordova/npm/node_modules/mongodb/lib/mongodb/db.js:1194:31
W20150822-22:58:09.216(1)? (STDERR)     at /Users/malcolm/.meteor/packages/mongo/.1.1.0.1ruc6ua++os+web.browser+web.cordova/npm/node_modules/mongodb/lib/mongodb/db.js:1903:9
W20150822-22:58:09.216(1)? (STDERR)     at Server.Base._callHandler (/Users/malcolm/.meteor/packages/mongo/.1.1.0.1ruc6ua++os+web.browser+web.cordova/npm/node_modules/mongodb/lib/mongodb/connection/base.js:453:41)
W20150822-22:58:09.216(1)? (STDERR)     at /Users/malcolm/.meteor/packages/mongo/.1.1.0.1ruc6ua++os+web.browser+web.cordova/npm/node_modules/mongodb/lib/mongodb/connection/server.js:487:18
W20150822-22:58:09.216(1)? (STDERR)     at [object Object].MongoReply.parseBody (/Users/malcolm/.meteor/packages/mongo/.1.1.0.1ruc6ua++os+web.browser+web.cordova/npm/node_modules/mongodb/lib/mongodb/responses/mongo_reply.js:68:5)
W20150822-22:58:09.216(1)? (STDERR)     at [object Object].<anonymous> (/Users/malcolm/.meteor/packages/mongo/.1.1.0.1ruc6ua++os+web.browser+web.cordova/npm/node_modules/mongodb/lib/mongodb/connection/server.js:445:20)
W20150822-22:58:09.216(1)? (STDERR)     at [object Object].emit (events.js:95:17)
W20150822-22:58:09.216(1)? (STDERR)     at [object Object].<anonymous> (/Users/malcolm/.meteor/packages/mongo/.1.1.0.1ruc6ua++os+web.browser+web.cordova/npm/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:207:13)
W20150822-22:58:09.217(1)? (STDERR)     at [object Object].emit (events.js:98:17)
4

1 回答 1

1

既然我已经解决了,答案似乎很明显。

无法读取 mocha db 的用户是 MONGO_URL 中的用户,在本例中为myUser

export MONGO_URL="mongodb://myUser:password@localhost/mydb/?authSource=admin"

您必须为您的生产数据库(在本例中)和数据库赋予myUser一个角色。readWritemydbmocha

于 2015-08-30T14:33:42.710 回答