你好,我的命令似乎有些不对劲 . 我可以用Robo 3T连接到我的mongodb . 但是,如果我做一个连接字符串 .
let url = mongodb://root:PASSWORD@10.0.1.185:27017/tbAuth
mongoose.connect(url, { auto_reconnect: true })
.catch((err) => {
console.error('App starting error:', err);
错误:
App starting error: { MongoError: Authentication failed.
at Function.MongoError.create (/var/app/current/node_modules/mongodb-core/lib/error.js:31:11)
at /var/app/current/node_modules/mongodb-core/lib/connection/pool.js:489:72
at authenticateStragglers (/var/app/current/node_modules/mongodb-core/lib/connection/pool.js:435:16)
at Connection.messageHandler (/var/app/current/node_modules/mongodb-core/lib/connection/pool.js:469:5)
at Socket. (/var/app/current/node_modules/mongodb-core/lib/connection/connection.js:321:22)
at emitOne (events.js:116:13)
at Socket.emit (events.js:211:7)
at addChunk (_stream_readable.js:263:12)
at readableAddChunk (_stream_readable.js:250:11)
at Socket.Readable.push (_stream_readable.js:208:10)
at TCP.onread (net.js:594:20)
name: 'MongoError',
message: 'Authentication failed.',
ok: 0,
errmsg: 'Authentication failed.',
code: 18,
codeName: 'AuthenticationFailed' }
或者如果我通过ssh ssh到服务器并尝试连接
mongo -u root -p PASSWORD
它失败 .
身份验证机制是SCRAM-SHA-1它明确声明它是身份验证错误 .
MongoDB shell version v3.6.3
connecting to: mongodb://%2Fopt%2Fbitnami%2Fmongodb%2Ftmp%2Fmongodb-27017.sock/
MongoDB server version: 3.6.3
2018-03-31T22:44:44.238+0000 E QUERY [thread1] Error: Authentication failed. :
DB.prototype._authOrThrow@src/mongo/shell/db.js:1608:20
@(auth):6:1
@(auth):1:2
exception: login failed
任何想法可能是什么问题?我已经删除了auth要求并重置了用户的密码但它仍然失败..如果我删除auth要求一切正常,所以服务器可以访问并且db正在运行 .
服务器在使用bitnami创建的aws上 .