Skip to content

Conversation

@scottnemes
Copy link
Contributor

Description

Updates the password handling functionality as follows:

  1. Add ability to use the -p flag to launch a password prompt (or to enter cleartext as before)
  2. Check for -p flag at the earliest possible point to reduce prompt load time (still limited by startup time)
  3. Allow for an empty string password from the envvar MYSQL_PWD
  4. Clarify password option hierachy:
    1. -p / --pass/--password CLI options
    2. envvar (MYSQL_PWD)
    3. DSN (mysql://user:password)
    4. cnf (.my.cnf / etc)
    6. --password-file CLI option
  5. Removes password prompt logic from the reconnect logic to reduce redundancy. Reconnections should still work fine from testing.

Closes #341

Checklist

  • I've added this contribution to the changelog.md.
  • I've added my name to the AUTHORS file (or it's already there).
  • I ran uv run ruff check && uv run ruff format && uv run mypy --install-types . to lint and format the code.

@scottnemes
Copy link
Contributor Author

@rolandwalker
The two points from the original issue were basically:

  1. Get a password prompt to the user faster
  2. Make -p open a prompt like the vendor client does

For the first point, this moves the -p logic to the earliest possible place. It's at best a minuscule amount faster, but barely noticeable. The majority of the delay is the "startup" time, which just takes a bit. But with this, any improvements we do make in the future to speed up the startup time will further reduce the time until password prompt.

For the second point, -p will now be usable by itself (just -p) to open a password prompt. It can also be used to enter the password in cleartext, like "-pMYPASS or -p MYPASS". That is the one difference with the vendor client; with the vendor client you can't do "-p MYPASS" as it treats the value as the DB when there is a space in between. I could not duplicate that functionality with click. I don't believe that's a big deal, but wanted to point it out anyway.

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

Successfully merging this pull request may close these issues.

Startup time causes password entry to display in terminal

1 participant