Bug #109661 mysqlsh 8.0.32 is executed without arguments it try to connect using [client]
Submitted: 17 Jan 2023 13:57 Modified: 17 Jan 2023 15:47
Reporter: DBA Provincia de Santa Fe Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S3 (Non-critical)
Version:8.0.32 OS:Ubuntu
Assigned to: CPU Architecture:x86
Tags: mysqlsh, mysqlshell

[17 Jan 2023 13:57] DBA Provincia de Santa Fe
Description:
When I executed mysqlsh without arguments it try to connect to some default user connection config.

$mysqlsh

MySQL Shell 8.0.32

Copyright (c) 2016, 2023, Oracle and/or its affiliates.
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 Classic session to 'user@localhost:5701'
Module matplotlib is not present, collected data won't be plotted.
MySQL Error 2003 (HY000): Can't connect to MySQL server on 'localhost:5701' (111)

I tried mysqlsh --no-defaults and got the same

How to repeat:

$mysqlsh

MySQL Shell 8.0.32

Copyright (c) 2016, 2023, Oracle and/or its affiliates.
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 Classic session to 'user@localhost:5701'
Module matplotlib is not present, collected data won't be plotted.
MySQL Error 2003 (HY000): Can't connect to MySQL server on 'localhost:5701' (111)

I tried mysqlsh --no-defaults and got the same

Printing defaults:
mysqlsh  --print-defaults
mysqlsh would have been started with the following arguments:
--user=user --password=***** --host=localhost --port=5701 

mysql_config_editor print --login-path=client
[client]
user = "user"
password = *****
host = "localhost"
port = 5701

Only after removing "client" from mysql_config_editor I was able to run without error

mysql_config_editor remove --login-path=client

$ mysqlsh 

MySQL Shell 8.0.32

Copyright (c) 2016, 2023, Oracle and/or its affiliates.
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.
That behavior was different on mysqlsh < 8.0.32

Suggested fix:
mysql_config_editor print --login-path=client
[17 Jan 2023 14:46] DBA Provincia de Santa Fe
It's a feature:

https://dev.mysql.com/doc/refman/8.0/en/option-file-options.html#option_general_no-default...

The exception is that client programs read the .mylogin.cnf login path file, if it exists, even when --no-defaults is used. This permits passwords to be specified in a safer way than on the command line even if --no-defaults is present. 

To avoid that behavior (try to connect when mysqlsh start) we need to remove [client] config or use a non default location for .mylogin.cnf
[17 Jan 2023 14:53] DBA Provincia de Santa Fe
Ignoring/deleting [client] config:

1- $ export MYSQL_TEST_LOGIN_FILE=''
   $ mysqlsh 

MySQL Shell 8.0.32

Copyright (c) 2016, 2023, Oracle and/or its affiliates.
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.
 MySQL  JS > 

2- Delete [client] config:

$ mysql_config_editor print delete --login-path=client

   $ mysqlsh 

MySQL Shell 8.0.32

Copyright (c) 2016, 2023, Oracle and/or its affiliates.
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.

 MySQL  JS >