Closed MiruhiMiruhi closed 6 years ago
The password is set at runtime. When you connect to a mongo instance and set the username on the settings, there should be a prompt input asking for password. You can input the password there for connection. Below is an example of configuration
"connection": {
"activeOnStartUp": true,
"url": "mongodb://hostname:port/databaseName",
"user": "admin"
}
Please let me know if it doesn't work for you.
Fixed in the latest version
+1
@ThomasGHenry Could you give more info on this issue? What is your configuration and what error did you get?
Thanks!
I know the DEV config probably wouldn't work, but I modeled the LIVE one on the comments here, and it still doesn't work. The same config works on my live server though, as well as via compass.
// ... other settings in settings.json ...
"mongoRunner": {
"connections": [
{
"name": "LIVE",
"url": "mongodb://blah.mlab.com:port1/blah",
"user": "blah_user"
},
{
"name": "DEV",
"url": "mongodb://blah_user:password@blah.mongodb.net:port2,blah.mongodb.net:port2,blah.mongodb.net:port2/test?ssl=true&replicaSet=blah-shard-0&authSource=admin&retryWrites=true"
}
]
},
// ... other settings in settings.json ...
Thanks, again!
"mongoRunner": {
"connection": {
"name": "LIVE",
"url": "mongodb://blah.mlab.com:port1/blah",
"user": "blah_user"
}
},
Same thing. It prompts for the password when I try to connect and the dialog shows the correct user and host, but then the connection fails. I didn't see logs any obvious place. Are there any?
What is the version of your mongodb server?
And what do you mean by The same config works on my live server though
? Does the LIVE
config work or not?
Sorry. I see the ambiguity in how I explained that. I mean the attributes that this config represents work elsewhere. My server (ExpressJS) can connect to that mongo host with the port, user, password, etc that I'm using in this mongo runner config. I can also connect with those parameters from the mongo GUI (compass, I think it's called). I'm not at the computer right now, but I'll look into the mongo version ASAP. It's whatever you get by default on mlab. Thanks again!
EDIT: Answers. The LIVE config doesn't work (per above). I believe the MongoDB version is 3.6 because that's the mlab default. I'll confirm later today.
mongod version: 3.6.6 (MMAPv1)
I created a mongodb 3.6.6.
and use below command to create an user.
db.createUser(
{
user: "reportsUser",
pwd: "12345678",
roles: [
{ role: "read", db: "reporting" },
{ role: "read", db: "products" },
{ role: "read", db: "sales" },
{ role: "readWrite", db: "accounts" }
]
}
)
And I am able to connect to the server by below configuration.
"mongoRunner": {
"connections": [
{
"name": "conn1",
"url": "mongodb://localhost:27017/test",
"user": "reportsUser"
}
]
},
Are you able to connect to the server via mongo shell with this url pattern? $ mongo mongodb://reportsUser:12345678@localhost:27017/test
.
In reality url": "mongodb://blah.mlab.com:port1/blah"
ended up being more like url": "mongodb://blah.mlab.com:port1/blahX",
. Please accept my shame and gratitude.
🤦♂️ Thanks!
Can't connect even with the correct password