Command line login fail

Hi,

I got this error from command line ‘mongo’ (per connect method from the company site). Could someone point me to the right direction? I migrated to atlas from classic mongo about month so ago.

Thank you!!

Mike

2021-01-03T10:15:04.722-0500 I NETWORK  [js] Marking host cluster0-shard-00-01.l4a1z.mongodb.net:27017 as failed :: caused by :: Location8000: can't authenticate against replica set node cluster0-shard-00-01.l4a1z.mongodb.net:27017 :: caused by :: Authentication failed.
2021-01-03T10:15:04.722-0500 E QUERY    [js] Error: can't authenticate against replica set node cluster0-shard-00-01.l4a1z.mongodb.net:27017 :: caused by :: Authentication failed. :
DB.prototype._authOrThrow@src/mongo/shell/db.js:1685:20
@(auth):6:1
@(auth):1:2
exception: login failed

This usually means wrong user name or password. Verify your credentials.

Welcome to the MongoDB community @Michael_Chen!

As @steevej suggested, a likely issue is that you have the wrong credentials for connecting to Atlas.

Note that the credentials for Atlas User Access (logging in via the Atlas UI) are not the same as those for a Database User. If you are trying to use an email address as the username in your mongo shell connection, it is likely that is an Atlas User rather than a Database User.

I would also check that you are using a version of the mongo shell which is at least as new as the server version your Atlas cluster is using. If you are using a significantly older shell, it may be lacking required support for TLS encryption or compatible authentication methods.

For more suggestions on authentication issues, please see the Atlas guide to Troubleshoot Connection Issues.

If you are still having trouble connecting, please provide an example of the mongo command line you are using (with any user/password/cluster details replaced) as well as the output of mongo --version.

Thanks,
Stennie

I think I got it. You all right.

Am bit lazy to figure out after classic mongo to atlas mongo why the code is not returning the expected result. I can see the data is there (via online dashboard)

const client = new MongoClient(uri, { useNewUrlParser: true });

client.connect(err => {
const collection = client.db(“mydb”).collection(“mycollection”);
// dont seems show any my data in ‘collection’ ???
});