I have created mongodb user with command
use admin
db.createUser(
{
user: \"superuser\",
pwd: \"12345678\",
roles: [ \"root\" ]
}
)
You must declare the authSource parameter in your connection string in order to specify the name of the database that contains your user's credentials:
var options = {
user: "superuser",
pass: "12345678"
};
var mongooseConnectionString = 'mongodb://localhost/twitter-mongo?authSource=admin';
Note: for users of Mongoose 4.x, you may want to also include useMongoClient: true
in your options object. This silences the Please authenticate using MongoClient.connect with auth credentials and open() is deprecated error messages.