How to connect from MongoDB Atlas version 4.4 to Mongo DB Shell? - mongodb-atlas

I copied the Mongo DB Shell connection string from Mongo DB Atlas and pasted to Mongo DB Shell. I got the following error.
Please enter a MongoDB connection string (Default: mongodb://localhost/): mongo "mongodb+srv://cluster0.h75mayj.mongodb.net/myFirstDatabase" --username Kirushiraam
Please enter a MongoDB connection string (Default: mongodb://localhost/): mongo "mongodb+srv://cluster0.h75mayj.mongodb.net/myFirstDatabase" --username Kirushiraam
MongoshInvalidInputError: [COMMON-10001] Invalid URI: mongo "mongodb+srv://cluster0.h75mayj.mongodb.net/myFirstDatabase" --username Kirushiraam
Press any key to exit:
I'm expecting Mongo DB shell connect the Mongo DB Shell connection string to load the queries

Related

Unable to connect to MongoDB Atlas Cluster from Mongosh terminal

I am trying to connect to the Mongo Atlas Cluster through the Mongosh terminal using mongosh "mongodb+srv://cluster0.sdwcf.mongodb.net/myFirstDatabase" --username <username>. But I am unable to connect the error being Error: queryTxt ETIMEOUT cluster0.sdwcf.mongodb.net. I found the same issue at https://github.com/metabase/metabase/issues/9867 but issue has been closed without any solution.
One the other hand if I try to connect using the mongo 3.4 or earlier command mongo "mongodb://cluster0-shard-00-00.sdwcf.mongodb.net:27017,cluster0-shard-00-01.sdwcf.mongodb.net:27017,cluster0-shard-00-02.sdwcf.mongodb.net:27017/myFirstDatabase?replicaSet=atlas-10n7hz-shard-0" --ssl --authenticationDatabase admin --username <username> --password <password> it works just fine. But given that the Mongosh terminal has superseded the Mongo terminal, I would really like to know if there is any fix for this..

Connect to Mongo DB cluster

I can execute Mongo in Command but I can`t execute the command to connect to the mongoDB cluster and
with mongoshell
what`s the problem.....
Mongo atlas⇒Clusters connect ⇒connect with mongo shell⇒ mongo shell version is correct
⇒Run your connection string in your command line⇒
⇒ mongo "mongodb+srv://xxxx.xxxxxxx/<dbname>" --username xxxxx
Then I have error...
what's the <dbname>? do I have to make a folder? where?
FailedToParse: Database name cannot have reserved characters for mongodb:// URL: mongodb+srv://xxxxxxx/
try 'mongo --help' for more information

error in connection mongodb atlas to shell

mongo "mongodb+srv://sandbox-hoj54.mongodb.net/test" --authenticationDatabase admin --username m001-student --password m001-mongodb-basics
2020-06-19T14:18:02.553+0530 E QUERY [js] uncaught exception: SyntaxError: unexpected token: string literal :
#(shell):1:6
I think the problem is that you are running this command:
mongo "mongodb+srv://cluster0-jxrfu.mongodb.net/<dbname>" --username <password> on the MongoDB shell you downloaded in your <your mongo shell's download directory>/bin directory.
Instead, Open up a new command line and run the command. It worked for me.
There are two options to connect to db. Connect with the mongo shell or connect your application. It seems that you are trying to connect by the shell. You can see your connection string in the window:
MongoDB Atlas Panel > Clusters > 'Connect' button.
Of course you have to replace <dbname> and <password> as in the description.

Format for MONGO_URL when connecting MongoDB Atlas to Galaxy

Revising this question following more attempts:
I'm deploying a Meteor app on Galaxy for the first time and cannot connect to MongoDB Atlas.
I can connect to MongoDb through Mongo Shell using:
mongo "mongodb://host1:27017,host2:27017,host3:27017/<db_name>?replicaSet=<replica_set_name>" --ssl --authenticationDatabase admin --username <username> --password <password>
I tried an equivalent for the Mongo URL in my settings.json:
mongodb://<username>:<password>#host1:27017,host2:27017,host3:27017/<db_name>?authSource=admin&replicaSet=<replace_set_name>
But when I deploy my app, I get:
Error: Could not locate any valid servers in initial seed list.
I've also tried using the connection string provided by Atlas:
mongodb+srv://<username>:<password>#<host>/<db_name>?retryWrites=true&w=majority
But this just returns:
Error: URL must be in the format mongodb://user:pass#host:port/dbname
I've tried every combination I can come up with but no luck.
RESOLVED, WITH HELP FROM MONGODB ATLAS SUPPORT:
"MONGO_URL": "mongodb://:#host1:27017,host2:27017,host3:27017/?ssl=true&replicaSet=&authSource=admin&retryWrites=true&w=majority",

How to connect to MongoDB on mLab through mongo shell?

I'm trying to connect to my database cluster on mLab through mongo shell using the commands as mentioned by the service providers but I keep getting the same error mentioning missing ";" statement. I can access the same database through mongoose client without any problem.
Any clue where I am messing up:
mongo ds117956.mlab.com:17956/image_search -u <dbuser> -p <dbpassword>
2017-11-29T03:04:33.139+0530 E QUERY [thread1] SyntaxError: missing ; before statement #(shell):1:6
you need to run from mongodb/bin
and then enter the following command: mongo ds117956.mlab.com:17956/image_search -u -p
not from mongo itself
mongo ds117956.mlab.com:17956/image_search -u -p