Mongoose: Как указать `--authenticationDatabase` в мангусте?

Созданный на 23 февр. 2016  ·  6Комментарии  ·  Источник: Automattic/mongoose

Работает в оболочке:

$ mongo -u monguser -p mongpass 192.168.2.2/ps --authenticationDatabase=admin
MongoDB shell version: 3.2.3
connecting to: 192.168.2.2/ps
Server has startup warnings: 
2016-02-23T01:59:10.522+0000 I CONTROL  [initandlisten] 
2016-02-23T01:59:10.522+0000 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2016-02-23T01:59:10.522+0000 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2016-02-23T01:59:10.522+0000 I CONTROL  [initandlisten] 
2016-02-23T01:59:10.522+0000 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2016-02-23T01:59:10.522+0000 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2016-02-23T01:59:10.522+0000 I CONTROL  [initandlisten] 
> db.foo.insert({can:'haz'})
WriteResult({ "nInserted" : 1 })

Сбой в мангусте:

'use strict';

const mongoose = require('mongoose');

const uri = 'mongodb://monguser:[email protected]:27017/ps'

console.log('mongoose.connect =', mongoose.connect(uri, (err) => {
    err && console.log('err =', err);
}));
// For `mongoose.connect` output, see: https://gist.github.com/SamuelMarks/dedd863742f90cf2f333
err = { [MongoError: Authentication failed.]
  name: 'MongoError',
  message: 'Authentication failed.',
  ok: 0,
  code: 18,
  errmsg: 'Authentication failed.' }

Поэтому можно предположить, что authenticationDatabase нужно как-то установить, возможно, в параметре конфигурации. _Какой синтаксис?_

Самый полезный комментарий

Самый простой способ - указать authSource в uri

const uri = 'mongodb://monguser:[email protected]:27017/ps?authSource=admin';

Все 6 Комментарий

Самый простой способ - указать authSource в uri

const uri = 'mongodb://monguser:[email protected]:27017/ps?authSource=admin';

Спасибо

@vkarpov15 ты спас мой день. Большое спасибо.

Кто-нибудь знает, как указать authSource при использовании команды mongodump? :]

@ORESoftware mongodump называет это authenticationDatabase : https://docs.mongodb.com/manual/reference/program/mongodump/#cmdoption -authenticationdatabase

Была ли эта страница полезной?
0 / 5 - 0 рейтинги