MongoDB: Can't connect to new replica set master

前端 未结 5 1625
南旧
南旧 2021-01-14 06:54

Trying to set up MongoDB for my Node.JS application. I running this command:

mongo \"mongodb+srv://cluster0-gjc2u.mongodb.net/test\"  --username 

        
相关标签:
5条回答
  • 2021-01-14 07:18

    So you have to take care of 2 things.

    1) First off, having mongodb in your $PATH, create a .bash_profile under the home folder if you don't have it already, then insert the following.(For Ubuntu)

    export PATH="$PATH:/usr/bin/mongo" Make sure you place the location of mongo on your computer. If you don't know the location, type whereis mongo on the terminal. After saving, type source ~/.bashrc in the terminal.

    2) Lastly, copy the connect link from the mongodb atlas, and when asked for username and password

    please provide the credentials set to access the database not the mongdb atlas account.

    0 讨论(0)
  • 2021-01-14 07:20

    What I tried was:

    1. Create new user
    2. Made sure the username and password for my mongoURI when connecting my application is the same as the username and password for when I connect with the mongo shell.
    3. Run your connection string in your command line in your application.
    0 讨论(0)
  • 2021-01-14 07:28

    This resolution might be specific for the mLabs to MongoDB Atlas migration tool provided by Cloud MongoDB.

    My resolution was to:

    1. Re-create the user with the same user name
    2. Change from spesific mLabs grants to Atlas built-in roles
    3. Set new credentials, I also avoided using special chars.

    Good luck!

    0 讨论(0)
  • 2021-01-14 07:28

    Create a simple password which doesn't have any special characters, it only includes alphabets and numbers.

    I wasn't able to access but changing password worked for me.

    0 讨论(0)
  • 2021-01-14 07:39

    I realise that "just wait a bit" isn't a terribly constructive answer, but I had the same issue and no luck in finding a solution, so left it for a couple hours and came back to find it working perfectly.

    The text that says your change has been deployed is misleading. Not sure why it takes several hours to kick in, but for reference I found this when using the M0 Sandbox cluster tier.

    0 讨论(0)
提交回复
热议问题