์ ธ์์ ์๋:
$ 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
๊ฐ ์ด๋ป๊ฒ๋ ์ค์ ๋์ด์ผ ํ๋ค๊ณ ๊ฐ์ ํ๋ ๊ฒ์ด ์ข์ต๋๋ค. ์๋ง๋ config ๋งค๊ฐ๋ณ์์ ์์ ๊ฒ์
๋๋ค. _๊ตฌ๋ฌธ์ ๋ฌด์์
๋๊น?_
๊ฐ์ฅ ์ฌ์ด ๋ฐฉ๋ฒ์ uri์ authSource
๋ฅผ ์ง์ ํ๋ ๊ฒ์
๋๋ค.
const uri = 'mongodb://monguser:[email protected]:27017/ps?authSource=admin';
๊ฐ์ฌ ํด์
@vkarpov15 ๋น์ ์ด ๋ด ํ๋ฃจ๋ฅผ ๊ตฌํ์ต๋๋ค. ์ ๋ง ๊ฐ์ฌํฉ๋๋ค.
mongodump ๋ช ๋ น์ ์ฌ์ฉํ ๋ authSource๋ฅผ ์ง์ ํ๋ ๋ฐฉ๋ฒ์ ์๋ ์ฌ๋์ด ์์ต๋๊น? :]
@ORESoftware mongodump๋ authenticationDatabase
๋ผ๊ณ ํฉ๋๋ค. https://docs.mongodb.com/manual/reference/program/mongodump/#cmdoption -authenticationdatabase
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
๊ฐ์ฅ ์ฌ์ด ๋ฐฉ๋ฒ์ uri์
authSource
๋ฅผ ์ง์ ํ๋ ๊ฒ์ ๋๋ค.const uri = 'mongodb://monguser:[email protected]:27017/ps?authSource=admin';