MongoDB Atlas - Can't connect to specific database

1,387 views
Skip to first unread message

Juan Gordon

unread,
Sep 10, 2016, 6:27:30 PM9/10/16
to mongodb-user
Hi to all,

I have a web application developed with django and mongoengine, and i'm using MongoDB atlas. I'm trying to connect to a specific database, but i can't, i'm only able to connect to the admin database. I'm using a connection string like this : 


i'm getting this error :

command SON([('saslStart', 1), ('mechanism', 'SCRAM-SHA-1'), ('autoAuthorize', 1), ('payload', Binary('n,,n=jgordon,r=OTU1MzY4NDg1MDI5', 0))]) on namespace MYDATABASE.$cmd failed: Authentication failed.

Does any one know what i'm doing wrong? any ideas?

Thanks a lot,

Juan

Wan Bachtiar

unread,
Sep 12, 2016, 11:29:36 PM9/12/16
to mongodb-user

Does any one know what i’m doing wrong? any ideas?

Hi Juan,

You should be able to connect via mongoengine to MongoDB Atlas using MongoDB Connection String URI format such below:

from mongoengine import connect  
connection_uri = "mongodb://[username:password@]@server1.mongodb.net:27017,server2.mongodb.net:27017,server3.mongodb.net:27017/databaseName?ssl=true&replicaSet=replicaSetName&authSource=admin"
connect('alias', host=connection_uri)

The above was tested using current version of mongoengine v0.10.6.

but i can’t, i’m only able to connect to the admin database

Could you confirm that you can connect using mongo shell and you have the required access to the database ? For example:

mongo "mongodb://[username:password@]@server1.mongodb.net:27017,server2.mongodb.net:27017,server3.mongodb.net:27017/admin?ssl=true&replicaSet=replicaSetName" --username [username]--password [password] --ssl

Then type on the mongo shell:


If you are still having trouble with MongoDB Atlas, please raise an issue on MongoDB Atlas Support page - while logged in on Atlas cluster page, follow the ‘Support’ link on the bottom left hand corner.

Regards,

Wan.

Reply all
Reply to author
Forward
0 new messages