Mongoose unable to connect authorized DB
Minbin Jiang Lv4

I installed the mongodb 3.4.1 on the ubuntu 16.04 and hosted them on digital ocean.

My local mongo client was mongochef 4.5.2

At first, i didn’t set up the authorization , it’s hacked, and i was asked for bitcoin as ransom.

So i tried to set up the authorization. However, encountered a wired problem, once set the authorization: enable in the /etc/mongo.conf . It’s unable to connect the db remotely and locally with the mongoose , and get the error **“auth failed”.  **. But it can be connected with the terminal and the mongoChef.

here is my connection with mongoose
global.db=mongoose.connect(‘mongodb://admin:admin123@ip:27017/nodedb’);

and i also tried

var options = {
user : “admin”,
pass : “admin123”,
auth : {authMechanism: ‘MONGODB-CR’}
}
global.db = mongoose.connect(‘mongodb://@ip:27017/test’,options);

and also changed the ip with localhost and 127.0.0.1 locally, failed the same.

Just in case the localhost and 127.0.0.1 didn’t recognised. Also set the configured the /etc/hosts

127.0.0.1 localhost
127.0.0.1 computename

really exhausted by this problem, has any one encounter this problem???