Cannot import dump from local machine to Atlas

Hi all.
I am trying to load a mongodb dump that I have on my local machine into atlas cluster.
I have not used atlas before apart from a small project. I have read everything that grows under the sun and i think i must have a silly issue that i cannot see.
I am on MACOS 10.14.6

the dump has been created with mongodump command (BSON files). I have:

  • uploaded the dump locally and it works well.

  • created 2 DB on atlas, all good

  • installed mongocli on my machine
    mongocli --version
    mongocli version: 1.15.1

    mongo --version
    MongoDB shell version v4.2.0

  • configured a user on atlas

  • created api keys and use mongocli config to set them up locally

now, 1st problem
mongo “mongodb+srv://cluster0.u7g3w.mongodb.net/beta” --username myusername

returns this error

2021-04-22T15:00:01.266+0800 I NETWORK [js] Marking host cluster0-shard-00-01.u7g3w.mongodb.net:27017 as failed :: caused by :: Location40659: can’t connect to new replica set master [cluster0-shard-00-01.u7g3w.mongodb.net:27017], err: AuthenticationFailed: bad auth : Authentication failed.

*** It looks like this is a MongoDB Atlas cluster. Please ensure that your IP whitelist allows connections from your network.

2021-04-22T15:00:01.348+0800 E QUERY [js] Error: bad auth : Authentication failed. :
connect@src/mongo/shell/mongo.js:341:17
@(connect):2:6
2021-04-22T15:00:01.353+0800 F - [main] exception: connect failed
2021-04-22T15:00:01.353+0800 E - [main] exiting with code 1

  • tried with atlas:

bad auth : Authentication failed.

I have another issue, which does not seem to be related:
when i try to run mongorestore, i get the message:
mongorestore: command not found

I have added mongo/bin to my PATH though, wondering if what i miss here
Any idea would be much appreciated!
Thank you

1 Like

Hi @Al_D,

Welcome to the community!

bad auth : Authentication failed.

This generally means credentials were entered incorrectly. I can see the connection string you posted was:
mongo “mongodb+srv://cluster0.u7g3w.mongodb.net/beta” --username

Did you remove the username from this post or is this the full command you had applied?
A username will need to be supplied after the --username option.

For example, connecting to the cluster as user atlasUser:

mongo “mongodb+srv://cluster0.u7g3w.mongodb.net/beta” --username atlasUser

You may find the following Atlas documentation useful:

If you’re choosing to use the same user credentials that you’re trying to perform the mongoshell connection from and credentials are entered incorrectly, then the mongorestore will also fail.

I have added mongo/bin to my PATH though, wondering if what i miss here

Have you tried running mongorestore from a new terminal after adding it to your PATH?

Kind Regards,
Jason

1 Like

thank you very much for taking the time to read and answer my question:
there was a typo in my command, i indeed passed my username after --username
mongo “mongodb+srv://cluster0.u7g3w.mongodb.net/beta” --username
then was prompted for my password
then got the error message above
(i edited my original post to reflect the change)

as for mongorestore and PATH, indeed i did not make it persist
I have added the new PATH to my .bash_profile now and still face the same error.
is it part of a different install?
Thank you very much for your help

1 Like

Hi @Al_D,

Thanks for clarifying the username.

there was a typo in my command, i indeed passed my username after --username
mongo “mongodb+srv://cluster0.u7g3w.mongodb.net/beta” --username
then was prompted for my password
then got the error message above

I would believe in this case if you’re still getting the bad Auth error, then I would double check the password if you are certain the username is correct. Alternatively, some additional troubleshooting steps you can take is to either add a new user / password combination or modify the current user’s password and try again.

as for mongorestore and PATH, indeed i did not make it persist
I have added the new PATH to my .bash_profile now and still face the same error.

Are you able to post the output from running export $PATH here? In addition to that, please change directories to the bin folder you have added to PATH and run ls -l to ensure mongorestore is in the bin folder. If you are unable to locate mongorestore, you can download MongoDB Database Tools which will contain mongorestore.

Alternatively, you can run mongorestore directly from the bin folder without needing to add it to PATH.

Hope this helps.

Kind Regards,
Jason

1 Like

Hi, thanks a lot for this

  1. with a new account / user password it works, so there must have be something wrong with my pass.
  2. mongorestore was not in the bin folder of the PATH, i did not notice
    thanks very much for your help
2 Likes