mongodb connection string code example

Example 1: mongodb local connection string

mongodb://localhost:27017/mydbname

Example 2: connection string mongodb with user

MongoClient.connect('mongodb://admin:password@localhost:27017/db', function (err, db) {

Example 3: can we replace a mongouri string with localhost

mongodb://mongodb0.example.com:27017

Example 4: mongodb connection string

mongodb://[username:password@]host1[:port1][,...hostN[:portN]][/[defaultauthdb][?options]]

Example 5: connection string mysql

Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;

Tags:

Misc Example