验证失败MongoDB Atlas

时间:2019-01-31 01:16:03

标签: javascript node.js mongodb

我正在尝试通过我的Node.js应用连接到MongoDB Atlas 我尝试的所有操作都会导致错误

我已经检查了官方手册和文档中的所有内容,但没有帮助

// my function 

 const mongoConnect = callback => {
      MongoClient.connect('mongodb+srv://user:(dummy)@cluster0-nmexz.mongodb.net/test?retryWrites=true', {
              useNewUrlParser: true
          })
          .then(client => {
              console.log('Connected!');
              callback(client);
          })
          .catch(err => console.log(err));
  }

//Calling function here

mongoConnect((client) => {
  console.log(client);
  app.listen(3000);
});

Despite provided correct credentials output is always:

MongoError: authentication fail
errors:
   [ { name: 'cluster0-shard-00-01-nmexz.mongodb.net:27017',
       err: [Object] },
     { name: 'cluster0-shard-00-00-nmexz.mongodb.net:27017',
       err: [Object] } ],
  name: 'MongoError',
  [Symbol(mongoErrorContextSymbol)]: {} }


0 个答案:

没有答案