Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Bug Fixes
--------
* Link to `--ssl`/`--no-ssl` GitHub issue in deprecation warning.
* Don't emit keyring-updated message unless needed.
* Include port and socket in keyring identifier.


1.49.0 (2026/02/02)
Expand Down
8 changes: 4 additions & 4 deletions mycli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,12 +600,12 @@ def connect(
# 5. cnf (.my.cnf / etc)
# 6. keyring

keychain_user = f'{user}@{host}'
keychain_identifier = f'{user}@{host}:{int_port}:{socket}'
keychain_domain = 'mycli.net'
keychain_retrieved = False

if passwd is None and use_keyring and not reset_keyring:
passwd = keyring.get_password(keychain_domain, keychain_user)
passwd = keyring.get_password(keychain_domain, keychain_identifier)
keychain_retrieved = True

# if no password was found from all of the above sources, ask for a password
Expand All @@ -614,9 +614,9 @@ def connect(

if reset_keyring or (use_keyring and not keychain_retrieved):
try:
saved_pw = keyring.get_password(keychain_domain, keychain_user)
saved_pw = keyring.get_password(keychain_domain, keychain_identifier)
if passwd != saved_pw or reset_keyring:
keyring.set_password(keychain_domain, keychain_user, passwd)
keyring.set_password(keychain_domain, keychain_identifier, passwd)
click.secho('Password saved to the system keyring', err=True)
except Exception as e:
click.secho(f'Password not saved to the system keyring: {e}', err=True, fg='red')
Expand Down