Bug #48674 Receiving error 1045 (28000): Access denied for user 'username'@'clientname'
Submitted: 10 Nov 2009 19:17 Modified: 10 Nov 2009 20:31
Reporter: Craig Matthews Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S2 (Serious)
Version:5.1.40 OS:Microsoft Windows (Windows 7 x86 and Windows Server 2008 R2 x64)
Assigned to: CPU Architecture:Any
Tags: 1045, access denied

[10 Nov 2009 19:17] Craig Matthews
Description:
Receiving ERROR 1045 (28000): Access denied for user 'username'@'clientname' (using password: YES)
in response to
mysql -h ServerName -u username -password=AbC
using the MySQL CLI on a Windows 7 (x86) system talking to MySQL server running on a Windows Server 2008 R2 (x64) system.

Notice that the password is "AbC" (lower case B).

I could not figure out why I could not connect until I mistakenly used
mysql -h ServerName -u username -p AbC
and when prompted from the password entered AbC, and received
ERROR 1049 (42000): Unknown database 'abc'

Notice that the password of "AbC" is being seen as "abc" (all lowercase instead of mixed case).

How to repeat:
Try to connect via the MySQL CLI from the command line passing the password containing mixed case.

Suggested fix:
Retrieve, and pass, the password from the command line in the case entered as if it were entered at the "Enter password:" prompt.
[10 Nov 2009 20:10] Peter Laursen
this is not mix-cased problem!

Just try:
C:\Program Files\MySQL\MySQL Server 5.1\bin>mysql -uroot -pmypass
or
C:\Program Files\MySQL\MySQL Server 5.1\bin>mysql -uroot -pmypass somedatabase
[10 Nov 2009 20:10] Miguel Solorzano
Thank you for the bug report. I couldn't repeat:

c:\dbs>5.1\bin\mysql -uroot --port=3510 -hlocalhost
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.42-Win X64-log Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> grant all on *.* to "username"@"localhost" identified by "AbC";
Query OK, 0 rows affected (0.38 sec)

mysql> exit
Bye

c:\dbs>5.1\bin\mysql -uusername --port=3510 -hlocalhost -pAbC
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.42-Win X64-log Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> exit
Bye

c:\dbs>5.1\bin\mysql -uusername --port=3510 -hlocalhost --password=AbC
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.1.42-Win X64-log Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>
[10 Nov 2009 20:31] Craig Matthews
The problem I had was connecting from Windows 7 (x86) to MySQL Server running on Windows Server 2008 R2 (x64).

I suspect that the problem is on the Windows Server 2008 R2 (x64) end. I just tried a command line containing the mixed case password as if it were a database name, and the uppercase characters were displayed as lowercase.

However, using the -pmypass (with no space between the -p and the password) works, but the -password=mypass does not. Strange inconsistency.
[10 Nov 2009 21:00] Peter Laursen
@Craig .. is it this small thing only?

this is wrong (single hyphen):
mysql -h ServerName -u username -password=AbC

correct is (double hyphen)
mysql -h ServerName -u username --password=AbC

.. I believe in the first example it gets interpreted like (p)+(assword=AbC) .. ie. it tries to authenticate with password "assword=AbC"

(common unix-type command syntax used by MySQL programs is single hyphen (-) for short parameter form and double hyphen (--) for long parameter form).
[5 Nov 2011 0:42] Rick James
On the commandline, do not have a space between -p and the password.