I am using Nodejs at server using mongoskin and using cluster mongo database. I am using EC2 bitnami to built all the servers. From the application log, I print the database connection string which is as follow (Please ignore the ip address, i just put garbled value)
mongodb://username:password@22.344.345.444:27017,username:password@44.55.665.44:27017,username:password@23.543.345.345:27017/mydb?replicaSet=myDBReplicaCluster
Its very surprising to me that it always connect to "admin" database. It is not connecting to the "mydb" database as defined in the connection string. I have tried everything however not able to understand the problem. Following are all details node module used:
"dependencies": {
"express": "4.9.8",
"body-parser": "1.9.0",
"connect-busboy": "0.0.2",
"cookie-parser": "1.3.3",
"express-session": "1.9.0",
"passport": "0.2.1",
"passport-local": "1.0.0",
"connect-flash": "0.1.1",
"connect-mongoskin": "*",
"morgan": "1.4.0",
"ejs": "1.0.0",
"bcrypt-nodejs": "0.0.3",
"mongodb": "1.4.19",
"mongoskin": "1.4.4",
"string": "2.2.0",
"unzip": "0.1.11",
"node-fs":"0.1.7",
"xml2js":"0.4.4",
"log4js":"0.6.21",
"helmet":"0.5.2",
"csurf":"1.6.3",
"underscore":"1.7.0",
"validator":"3.22.2",
"elasticsearch":"*"
},
"devDependencies": {
"grunt": "0.4.5",
"chai": "1.9.2",
"mocha": "1.21.5",
"karma": "0.12.24",
"grunt-contrib-copy": "0.7.0",
"grunt-contrib-clean": "0.6.0",
"grunt-contrib-uglify": "0.6.0",
"grunt-contrib-jshint": "0.10.0",
"grunt-simple-mocha": "0.4.0",
"grunt-exec": "0.4.6",
"karma-script-launcher": "0.1.0",
"karma-chrome-launcher": "0.1.5",
"karma-firefox-launcher": "0.1.3",
"karma-ie-launcher": "0.1.5",
"karma-jasmine": "0.1.5",
"karma-phantomjs-launcher": "0.1.4",
"karma-story-reporter": "0.2.2",
"grunt-karma": "0.9.0",
"grunt-cli": "0.1.13",
"karma-sauce-launcher": "0.2.10",
"phantomjs": "1.9.11",
"karma-ng-html2js-preprocessor": "0.1.1",
"node-inspector": "0.7.4",
"protractor": "*",
"grunt-protractor-runner": "1.1.4",
"grunt-contrib-htmlmin": "0.3.0",
"grunt-bump": "0.0.16",
"node-gyp":"*",
"grunt-sass":"*",
"frisby":"*",
"jasmine-node":"*",
"grunt-jasmine-node":"*",
"grunt-contrib-watch":"*"
}
Please help.
Your connection string is not formatted correctly according to the MongoDB URI format.
You should not have the username & password repeated; the correct format should be:
mongodb://username:password@22.344.345.444:27017,44.55.665.44:27017,23.543.345.345:27017/mydb?replicaSet=myDBReplicaCluster