Created a new mLab account and created the database according to the steps here http://docs.mlab.com/#create-sub . Trying to connect to the database using the mongo shell and mongoose Node.js, but I see an "Authentication Error" error in both cases.
There is a command in the Mongo shell, I double-checked the credentials
mongo ds012345.mlab.com:56789/dbname -u dbuser -p dbpassword
Error:
MongoError: authentication fail
at Function.MongoError.create (E:\Gatsby\notmongoose\node_modules\mongodb-core\lib\error.js:31:11)
Using Mongoose
var mongoose = require('mongoose')
, Admin = mongoose.mongo.Admin;
var uri = '<correct mongo uri here>';
var connection = mongoose.createConnection(uri,
{
User: '<uname>',
Password: '<pwd>'
});
connection.on('open', function() {
console.log('connection established!!!');
new Admin(connection.db).listDatabases(function(err, result) {
console.log('listDatabases succeeded');
console.log(err);
console.log(result);
});
});
Error :: MongoConnect Error MongoError: authentication failed
Is there anything else that needs to be done on the mLab console or something else that I might be doing wrong or missing?
source
share