mycli icon indicating copy to clipboard operation
mycli copied to clipboard

DSN with schema without user fails

Open mlopezgva opened this issue 6 months ago • 0 comments

Hi.

I have been trying to configure mycli to connect with several remotes through a tunnel. It seemed to work... until I "moved" the connection parameters to a DSN. If I call the DSN with an schema (--database test) but without a username, it fails. At first I thought it was related to the use of the --ssh arguments, but it happens locally, too:

[alias_dsn]
dcor     = mysql://root:root@docker_databases.local/

This database has some schemas in it (like 'test', 'work' and the internals, of course).

If I execute:

❯ mycli -d dcor -u root -D work
MariaDB 10.5.16
mycli 1.27.2
Home: http://mycli.net
Bug tracker: https://github.com/dbcli/mycli/issues
Thanks to the contributor - Johannes Hoff
root@docker_databases.local:work> \q
Goodbye!

But, since the username (along with the password) is defined in the DSN, and it's a bundle of 18 servers with their user and password each, my intention is to connect and "open" the database with the schema I want to. So, using the DSN and the database parameters should be enough:

❯ mycli -d dcor -D work
Could not find the specified DSN in the config file. Please check the "[alias_dsn]" section in your myclirc.

But it's not. It's clear it gathers the password from the DSN line, since using the -u root logs in directly,without prompting for the password. But if I do not use it, it fails.

This presents me a problem, because I'll have to pass the username if I want to log in directly to the schema I want to use (something I can script to make it shorter)... Or execute a use <schema> each time I log in.

Thank you for this piece of software, BTW. :smiley:

mlopezgva avatar Aug 20 '24 11:08 mlopezgva