Bug #107205 MySQL client connection doesn't ask terminal for password
Submitted: 4 May 2022 2:26 Modified: 26 Jun 2022 18:54
Reporter: LevelThree cPanel Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S3 (Non-critical)
Version:8.0.29 OS:CentOS (CentOS Linux release 7.9.2009 (Core))
Assigned to: CPU Architecture:Any
Tags: regression

[4 May 2022 2:26] LevelThree cPanel
Description:
After upgrading from 8.0.28-1 to 8.0.29-1, it was observed that passing option -p doesn't ask the terminal for a password.

===
[root@mysql-8 ~]# mysql -p
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 51
Server version: 8.0.29 MySQL Community Server - GPL

Copyright (c) 2000, 2022, 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 '\h' for help. Type '\c' to clear the current input statement.

mysql> 
===

It seems to function this way if a login file is used. The login file is used instead of prompting for the password when the option password is specified.

Removing login file ".my.cnf", allows the user to enter a password in terminal.

This change in functionality doesn't appear to be documented in any recent changes. Maybe this is a new issue due to the change in the recent bug fix?

===
Following changes in password handling in MySQL 8.0.27, if the mysql client was interrupted with Ctrl + C, a password prompt could be issued requiring the user’s password in order to action the interrupt. The password is now recorded when it is provided in response to a prompt (as well as when it is provided on the command line at startup), so it can be used automatically by the new connection that is established for the interrupt. (Bug #33514253)
===

How to repeat:
Install MySQL version 8.0.28
Create MySQL user
Create MySQL login file .my.cnf
Try logging in with "mysql -uUser -p"
Observe terminal is asking for password
Upgrade to MySQL version 8.0.29
Try logging in with "mysql -uUser -p"
Observe terminal no longer asks for the password

Suggested fix:
Unless this change is intentional, users should be able to enter their password in terminal even if a login file .my.cnf is present.
[4 May 2022 9:36] MySQL Verification Team
Hello!

Thank you for the report and feedback.
Verified as described.

regards,
Umesh
[26 Jun 2022 18:54] Margaret Fisher
Posted by developer:
 
Changelog entry added for MySQL 8.0.31:

Following a bug fix in MySQL 8.0.29, if the password was provided in an option file, the mysql client did not prompt for a password if the -p option was specified at login. The client now always prompts for a password when the -p option is specified and uses the specified password, even if an alternative was populated from an option file.