Saturday, April 20, 2019

Connection String - MongoDB

Replica Set - Connection String:
-----------------------------------

/data/usr/mongodb/bin/mongo --host rs0/server1:27018,server2:27018 -u user_name -p password --authenticationDatabase admin

/data/usr/mongodb/bin/mongo mongodb://user_name:password@server1:27018,server2:27018/admin?replicaSet=rs0

-----------------------------------------------------------

Sharded Cluster - Connection String:
--------------------------------------

/data/usr/mongodb/bin/mongo --port 27017 -u user_name -p password --authenticationDatabase admin
/data/usr/mongodb/bin/mongo mongodb://user_name:password@server1:27017/admin

-----------------------------------------------------------

Authenticate and connect to test DB
--------------------------------------

/data/usr/mongodb/bin/mongo mongodb://user_name:password@server1:27017/test?authSource=admin

-----------------------------------------------------------

without Authentication:
----------------------------

/data/usr/mongodb/bin/mongo mongodb://server1:27017,server2:27017,server3:27017/admin?replicaSet=rs0

------------------------------------------------------------

No comments:

Post a Comment