Bug #101441 Login path cannot be specified
Submitted: 3 Nov 2020 14:07 Modified: 23 Aug 2022 1:54
Reporter: Ceri Williams Email Updates:
Status: Duplicate Impact on me:
None 
Category:Shell General / Core Client Severity:S4 (Feature request)
Version:8.0.21, 8.0.22 OS:Any
Assigned to: CPU Architecture:Any
Tags: login-path, mysqlsh

[3 Nov 2020 14:07] Ceri Williams
Description:
Whilst mysqlsh appears to store connections in ~/.mylogin.cnf based upon the connection details when asked and automatically lookup from there to, it is not possible to create an arbitrary identifier and use this with --login-path

How to repeat:
=> mysql_config_editor print --all                                             

=> mysqlsh --socket=/tmp/mysql_sandbox8022.sock --user=root      
Please provide the password for 'root@/tmp%2Fmysql_sandbox8022.sock': ********
Save password for 'root@/tmp%2Fmysql_sandbox8022.sock'? [Y]es/[N]o/Ne[v]er (default No): Y
MySQL Shell 8.0.21

Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its affiliates.
Other names may be trademarks of their respective owners.

Type '\help' or '\?' for help; '\quit' to exit.
Creating a session to 'root@/tmp%2Fmysql_sandbox8022.sock'
Fetching schema names for autocompletion... Press ^C to stop.
Your MySQL connection id is 72
Server version: 8.0.22 MySQL Community Server - GPL
No default schema selected; type \use <schema> to set one.
 MySQL  localhost  JS > 
Bye!

=> mysql_config_editor print --all                         
[root@/tmp/mysql_sandbox8022.sock]
user = root
password = *****
socket = /tmp/mysql_sandbox8022.sock

=> mysql_config_editor set --login-path=test --user=root --socket=/tmp/mysql_sandbox8022.sock --password
Enter password: 

=> mysql_config_editor print --all                                                                      
[root@/tmp/mysql_sandbox8022.sock]
user = root
password = *****
socket = /tmp/mysql_sandbox8022.sock
[test]
user = root
password = *****
socket = /tmp/mysql_sandbox8022.sock

=> mysqlsh --user=root test
Please provide the password for 'root@test': ********
MySQL Shell 8.0.21

Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its affiliates.
Other names may be trademarks of their respective owners.

Type '\help' or '\?' for help; '\quit' to exit.
Creating a session to 'root@test'
MySQL Error 2005: No such host is known 'test'

=> mysqlsh --login-path=test
mysqlsh: unknown option --login-path

Suggested fix:
Enable use of --login-path or fix auto-lookup
[4 Nov 2020 13:01] MySQL Verification Team
Hello Ceri Williams,

Thank you for the reasonable feature request.
Verifying as a feature request to include the --login-path option considering other CLI have --login-path options such as
mysql - https://dev.mysql.com/doc/refman/8.0/en/mysql-command-options.html#option_mysql_login-path
mysqldump - https://dev.mysql.com/doc/refman/8.0/en/mysqladmin.html#option_mysqladmin_login-path
mysqlcheck - https://dev.mysql.com/doc/refman/8.0/en/mysqlcheck.html#option_mysqlcheck_login-path
etc

Since MySQL Shell 8.0.12+, there is a new feature which allows users to store and automatically retrieve their MySQL account credentials. This enables them to seamlessly work with various servers without explicitly providing the password for each new connection and create secure unattended scripts which do not need to include plain text passwords. - https://dev.mysql.com/doc/mysql-shell/8.0/en/mysqlsh.html#option_mysqlsh_credential-store-...

There are two additional special values which can be used to set the "credentialStore.helper" option:

    "<disabled>" – disables the automatic storage/retrieval of credentials,
    "default" – selects the default helper on the current platform.

The default helpers are currently:

    "windows-credential" – on Windows platform,
    "keychain" – on macOS platform,
    "login-path" – on all remaining platforms.

The login-path helper uses mysql_config_editor utility and is able to work in compatibility mode with existing entries, for instance, the password stored using:

mysql_config_editor set --login-path="my-server" --user=account --host=10.0.2.15 --password
Enter password:

will be automatically retrieved by Shell.

More details are here - https://mysqlserverteam.com/mysql-shell-8-0-12-storing-mysql-passwords-securely/

regards,
Umesh
[23 Aug 2022 1:51] Alfredo Kojima
Posted by developer:
 
Duplicate FR
[23 Aug 2022 1:54] Alfredo Kojima
Duplicate of Bug#81279