javascript - mongodb Authentication failed.
黄舟
黄舟 2017-06-27 09:18:13
0
1
1167

Node provides services. In the development and production environment, the session data is placed in the memory. When it goes online, the heap out of memory appears, so connect-mongo is used to store the session in mongodb. Initially The test is written like this

var dbUrl = 'mongodb://localhost/mysessions';
mongoose.connect(dbUrl,{useMongoClient: true});
var options = {
    url: dbUrl,
    collection: 'sessions'
};
app.use(session({
    secret: '12345',
    name: 'test',
    cookie: {maxAge: 1 * 60 * 1000},
    resave: false,
    saveUninitialized: true,
    store: new MongoStore(options)
}));

But later changed dburl to:

var dbUrl = 'mongodb://jeremy:123456@localhost/mysessions';

在启动服务时报错了:


What is the reason and how to solve it?

黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

reply all(1)
ringa_lee

Check whether the user jeremy you created is created in the mysessions database.

For reference.

Love MongoDB! Have fun!

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template