mongolab / mongoctl

Manage MongoDB servers and replica sets using JSON configurations!
MIT License
178 stars 25 forks source link

Configure server connections by URI #5

Open srleo opened 11 years ago

srleo commented 11 years ago

I think this is an enhancement request, or else I just can't figure out your docs.

The reason I started using mongoctl was so that I could connect to my mongo servers using the mongodb:// uri instead of parsing it into {host, port, username, password, database} every time. But when setting up .mongoctl/servers.config I can't use the URI but need to parse it manually.

leopd commented 11 years ago

To be more clear about the use case I'm hoping for...

It would be great to be able to use mongoctl connect serverNickname as a shortcut for having to remember / copy-paste the full URI for various mongo servers I use, and to be able to configure them in servers.config. It's pretty close to this already, but I don't see how to configure username/password for connection in servers.config at all. It would be ideal if servers.config supported mongodb:// uris.

abdulito commented 11 years ago

Hello!

Unfortunately, mongoctl does not exactly have what you described. Good news is that it has something that is not too far from that. It is not fully documented though.

Using the connect command, you can connected to your database using something like:

# mongoctl connect SERVER_ID/dbname -u <dbusername> -p <dbpassword>

Now If you set your database credentials in the "seedUsers" property of your mongoctl server config, then just passing your username through "-u" would be enough. mongoctl will automatically lookup the password from your "seedUsers" property and provide it to connect.

So in your server config set "seedUsers" as follows:

"seedUsers": { "<dbname>": [ { "username": <string>, "password": <string> } ... ], ... } And then connect using

# mongoctl connect SERVER_ID/dbname -u <dbusername>

So this should work without needing to supply the password.

I hope this helps and apologies for the late reply.

Sincerely,

-abdul

pkaeding commented 9 years ago

I was hoping for this as well, and it is ironic that I can't use mongoctl to connect to my mongo server hosted by mongolab as easily as I can to connect to my own self-managed mongo servers.

Would it be possible to configure a 'default user', so you don't need to specify the user every time either?

abdulito commented 9 years ago

We are not planning for that unfortunately :( I suggest using an alias instead. Cheers!

maxko87 commented 8 years ago

I was tired of doing this conversion by hand so I made a tiny tool to do this myself. http://www.mongo.click/