[CONJ-480] Access denied error on connect to MySQL 5.1.73 Created: 2017-05-29  Updated: 2017-06-01  Resolved: 2017-06-01

Status: Closed
Project: MariaDB Connector/J
Component/s: Other
Affects Version/s: 2.0.2
Fix Version/s: 1.6.1, 2.0.2

Type: Bug Priority: Major
Reporter: J. Lewis Muir Assignee: Diego Dupin
Resolution: Fixed Votes: 0
Labels: None


 Description   

Using Java 8 and MariaDB Connector/J 2.0.2-SNAPSHOT to connect to a MySQL 5.1.73 database results in an "access denied" error. The connection is created like this:

try (Connection c = DriverManager.getConnection(url, user, new String(password))) {
  System.out.printf("Connection class:%n%s%n", c.getClass().getName());
}

where url is something like this:

"jdbc:mariadb://127.0.0.1:3306/MYDB"

and the result is the following stack trace:

Exception in thread "main" java.sql.SQLInvalidAuthorizationSpecException: Could not connect: Access denied for user 'luke'@'127.0.0.1' (using password: YES)
	at org.mariadb.jdbc.internal.util.exceptions.ExceptionMapper.get(ExceptionMapper.java:151)
	at org.mariadb.jdbc.internal.util.exceptions.ExceptionMapper.getException(ExceptionMapper.java:115)
	at org.mariadb.jdbc.internal.util.exceptions.ExceptionMapper.throwException(ExceptionMapper.java:89)
	at org.mariadb.jdbc.Driver.connect(Driver.java:108)
	at java.sql.DriverManager.getConnection(DriverManager.java:664)
	at java.sql.DriverManager.getConnection(DriverManager.java:247)
	at Main.main(Main.java:16)
Caused by: java.sql.SQLException: Could not connect: Access denied for user 'luke'@'127.0.0.1' (using password: YES)
Current charset is UTF-8. If password has been set using other charset, consider using option 'passwordCharacterEncoding'
	at org.mariadb.jdbc.internal.protocol.AbstractConnectProtocol.authentication(AbstractConnectProtocol.java:759)
	at org.mariadb.jdbc.internal.protocol.AbstractConnectProtocol.handleConnectionPhases(AbstractConnectProtocol.java:688)
	at org.mariadb.jdbc.internal.protocol.AbstractConnectProtocol.connect(AbstractConnectProtocol.java:400)
	at org.mariadb.jdbc.internal.protocol.AbstractConnectProtocol.connectWithoutProxy(AbstractConnectProtocol.java:1016)
	at org.mariadb.jdbc.internal.util.Utils.retrieveProxy(Utils.java:480)
	at org.mariadb.jdbc.Driver.connect(Driver.java:103)
	... 3 more

I also tried appending &passwordCharacterEncoding=UTF-8 to url, and another time &passwordCharacterEncoding=ISO-8859-1, neither of which helped.

Trying the same using MySQL Connector/J 5.1.42 (with mysql instead of mariadb in url) works fine.

Connecting using the mysql command line program from MySQL 5.7.18 works too, and, even though I doubt it matters, the \s command shows the following character set information:

Server characterset:	latin1
Db     characterset:	latin1
Client characterset:	utf8
Conn.  characterset:	utf8



 Comments   
Comment by Diego Dupin [ 2017-06-01 ]

MariaDB driver is compatible with 5.5.3 server minimum.
This issue will corrected in next version, because it's a very small correction.
But you must be aware that Stored procedure with INOUT/OUTPUT parameters won't work with 5.1 server, because Driver use a functionality to avoid exchanges with server.

correction is available through 2.0.2-SNAPSHOT :

<repositories>
    <repository>
        <id>sonatype-nexus-snapshots</id>
        <name>Sonatype Nexus Snapshots</name>
        <url>https://oss.sonatype.org/content/repositories/snapshots</url>
    </repository>
</repositories>
 
<dependencies>
    <dependency>
        <groupId>org.mariadb.jdbc</groupId>
        <artifactId>mariadb-java-client</artifactId>
        <version>2.0.2-SNAPSHOT</version>
    </dependency>
</dependencies>

Comment by J. Lewis Muir [ 2017-06-01 ]

Thank you! I confirm that 2.0.2-SNAPSHOT (i.e., mariadb-java-client-2.0.2-20170601.085036-4.jar) fixes the problem!

Generated at Thu Feb 08 03:15:58 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.