Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure server connections by URI #5

Open
srleo opened this issue Dec 13, 2012 · 5 comments
Open

Configure server connections by URI #5

srleo opened this issue Dec 13, 2012 · 5 comments

Comments

@srleo
Copy link

srleo commented Dec 13, 2012

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
Copy link

leopd commented Dec 13, 2012

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
Copy link
Contributor

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
Copy link

pkaeding commented Apr 9, 2015

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
Copy link
Contributor

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

@maxko87
Copy link

maxko87 commented May 6, 2016

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants