Bug #110545 mysql shell does not accept some parameters of defaults file

Submitted: 29 Mar 2023 11:18 Modified: 12 Jun 2024 12:25
Reporter: Eduardo Ortega (OCA) Email Updates:
Status: Not a Bug Impact on me:
None 
Category:Shell General / Core Client Severity:S3 (Non-critical)
Version:8.0.32 OS:Any
Assigned to: CPU Architecture:Any
Tags: mysqlsh, mysqlshell, shell

[29 Mar 2023 11:18] Eduardo Ortega
Description:
Several MySQL utilities can use defaults file, where the user can specify options that they want used by default to connections. Unfortunately, the shell does not seem to like/understand at least some options that other MySQL utilities do. 

Example:
```
[ 8752 ] user@host ~/sandboxes/msb_8_0_27 % ➜  cat my.sandbox.cnf |grep -v '^#.*' |head -n 10

[mysql]
prompt='mysql [\h:8027] {\u} (\d) > '

[client]
user               = msandbox
password           = msandbox
port               = 8027

[ 8754 ] user@host ~/sandboxes/msb_8_0_27 % ➜  mysql --defaults-file=my.sandbox.cnf -e 'select 1'
+---+
| 1 |
+---+
| 1 |
+---+

[ 8755 ] user@host ~/sandboxes/msb_8_0_27 % ➜  mysqlsh --defaults-file=my.sandbox.cnf
While processing defaults options:
mysqlsh: unknown option --default-character-set
```

This means that the same options file cannot currently be used for the shell and other utilities.

How to repeat:
See steps in the example given in the description.

Suggested fix:
If the option specified in the file makes sense, support it and use it. If it does not make sense for the shell, even if it does for other utilities, log a warning specifying that it is ignored instead of failing to start the shell.
[30 Mar 2023 18:13] Alfredo Kojima
I can't reproduce this, there's no default-character-set option in the cnf file that was pasted.
[31 Mar 2023 9:30] Eduardo Ortega
Apologies, the pipe to head was chopping the relevant part. Here it is:

```
[ 8828 ] user@some-host ~/sandboxes/msb_8_0_27 % ➜  cat my.sandbox.cnf |grep -v '^#.*' |head -n 12

[mysql]
prompt='mysql [\h:8027] {\u} (\d) > '

[client]
user               = msandbox
password           = msandbox
port               = 8027
socket             = /var/folders/8p/60l87z5s4v95qxxxp3q59fv00000gp/T/mysql_sandbox8027.sock
default-character-set = utf8mb4
```
[22 Dec 2023 12:58] MySQL Verification Team
Thank you for the bug report. Please try with latest version. Thanks.
[10 Jan 2024 14:16] Eduardo Ortega
It does not yet seem to work, neither with 8.0.35 nor with 8.2.1:

```
user@host ~/sandboxes/msb_8_0_33 % ➜  mysqlsh --version
mysqlsh   Ver 8.0.35 for macos13 on x86_64 - for MySQL 8.0.35 (MySQL Community Server (GPL))

user@host ~/sandboxes/msb_8_0_33 % ➜  mysqlsh --defaults-file=my.sandbox.cnf -sql -e 'select 1'
While processing defaults options:
mysqlsh: unknown option --default-character-set

user@host ~/sandboxes/msb_8_0_33 % ➜  mysqlsh --version
mysqlsh   Ver 8.2.1 for macos13 on x86_64 - for MySQL 8.2.0 (MySQL Community Server (GPL))

user@host ~/sandboxes/msb_8_0_33 % ➜  mysqlsh --defaults-file=my.sandbox.cnf -sql -e 'select 1'
While processing defaults options:
mysqlsh: unknown option --default-character-set
```
[26 Jan 2024 17:06] Dejan Radosevic
Shell 8.3.0 still complains about it. 
Meaning upgrade_checking of 8.0.36 to 8.3.0 is not possible !
[29 Jan 2024 11:15] Dejan Radosevic
ok, it seems that default-character-set is not needed. 
8.0.36 works normally without it.
[12 Jun 2024 12:25] MySQL Verification Team
Hello Eduardo Ortega,

Thank you for the bug report.
Discussed your issue internally with the developer and concluded that this is not a bug. 
Options that are not supported by all clients should either be moved from [client] to [mysql] etc  or prefixed with loose-

Regards,
Ashwini Patil

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.040 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.