Bug #65721 Error connecting with complex username using ODBC 3.51.30
Submitted: 24 Jun 2012 17:18 Modified: 24 Jun 2012 17:59
Reporter: Nathan Adams Email Updates:
Status: Verified Impact on me:
None 
Category:Connector / ODBC Severity:S2 (Serious)
Version:3.51.30 OS:Windows (Seen in XP)
Assigned to: CPU Architecture:Any
Tags: regression

[24 Jun 2012 17:18] Nathan Adams
Description:
Using a complex username such as 109&HKzE8E6 fails to connect with MySQL server 5.1.41. when using the Windows 3.51.30 ODBC driver. This is confirmed if using a configured host IP address or the wildcard %

This is seen in version 3.51.30 but is not seen in previous releases 3.51.27 tested. In 3.51.27 these complex usernames can connect to the database server without any problem.

Using simpler usernames such as 109ABC works OK with the same password and host address. This is a simple workaround but produces simpler usernames.

Enabling the GENERAL log produces this simple line when trying to connect:

120622 16:12:05 17225 Connect   Access denied for user '109&HKzE8E66'@'5e041a43.bb.sky.com' (using password: YES)

This is also seen on the ODBC driver when trying to connect.

How to repeat:
On the server create a complex username

CREATE USER '109&HKzE8E7'@'%' IDENTIFIED BY  '***';

GRANT USAGE ON * . * TO  '109&HKzE8E7'@'%' IDENTIFIED BY  '***' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ;

Open the windows control panel>administrative tools>data sources

select SYSTEM DSN and then ADD

Select MySQL ODBC 3.51

Enter TEST in the Data Source Name
Enter the IP address of the MySQL server
Enter complex username [  109&HKzE8E7 ]
Enter password

click TEST

Suggested fix:
No suggested fix only do not use these complex names you must use simpler names with this version of the driver 3.51.30.
[24 Jun 2012 17:30] Nathan Adams
Further testing confirms that the MySQL server is OK by connecting using the linux CLI:

mysql -u '109&HKzE8E7' -ptest

And also by connecting with the same username/password with phpMyadmin

Strongly suggest an issue with ODBC driver. Note when using the CLI the name must be included in quotes.
[24 Jun 2012 17:59] Valeriy Kravchuk
Thank you for the bug report. Verified on 32-bit Windows XP. Quoting username when creating DSN does not help. 

And, indeed, proper OS-level quoting allows to use this username from command line:

C:\Program Files\MySQL\MySQL Server 5.5\bin>mysql -u109&HKzE8E7 -puser -P3308 te
st
ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)
'HKzE8E7' is not recognized as an internal or external command,
operable program or batch file.

C:\Program Files\MySQL\MySQL Server 5.5\bin>mysql -u'109&HKzE8E7' -puser -P3308
test
ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)
'HKzE8E7'' is not recognized as an internal or external command,
operable program or batch file.

C:\Program Files\MySQL\MySQL Server 5.5\bin>mysql -u"109&HKzE8E7" -puser -P3308
test
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.24 MySQL Community Server (GPL)

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

mysql> select current_user();
+-----------------------+
| current_user()        |
+-----------------------+
| 109&HKzE8E7@localhost |
+-----------------------+
1 row in set (0.03 sec)