| Bug #19820 | Connecting with java application to Mysql gives access denied | ||
|---|---|---|---|
| Submitted: | 15 May 2006 15:21 | Modified: | 18 May 2006 20:41 |
| Reporter: | Trevor Williams | Email Updates: | |
| Status: | Not a Bug | Impact on me: | |
| Category: | MySQL Server | Severity: | S1 (Critical) |
| Version: | 4.1.10a | OS: | Linux (Red Hat Linux ES ver 4.0) |
| Assigned to: | CPU Architecture: | Any | |
[15 May 2006 18:35]
Valeriy Kravchuk
Thank you for a problem report. Please, comment with mysql command line client and sen the results of: select host, user from mysql.user\G Will you see localhost.localdomain amond the values of host column?
[16 May 2006 6:18]
Trevor Williams
I typed the commands given and the results are shown below with the user trevor in rows 8 and 9. mysql> select host, user from mysql.user\G; *************************** 1. row *************************** host: % user: chrisg *************************** 2. row *************************** host: gemsbok.cg-a.co.za user: *************************** 3. row *************************** host: gemsbok.cg-a.co.za user: chrisg *************************** 4. row *************************** host: gemsbok.cg-a.co.za user: root *************************** 5. row *************************** host: localhost user: *************************** 6. row *************************** host: localhost user: chrisg *************************** 7. row *************************** host: localhost user: root *************************** 8. row *************************** host: localhost user: trevor *************************** 9. row *************************** host: localhost.localdomain user: trevor 9 rows in set (0.02 sec) ERROR: No query specified
[16 May 2006 19:15]
Valeriy Kravchuk
As you can connect from mysql command line client, from the same machine, please, send the results of select user(); while you are connected.
[18 May 2006 11:23]
Trevor Williams
I managed to resolve the issue by uncovering a bug in the GRANT system. I had created a user 'trevor' and a user 'trevor@localhost' using the grant command giving select, update and insert privileges. When the java app ran it somehow made a 'trevor@localhost.localdomain'. I then tried in vain to grant rights to the new user until I used the 'update table set Insert_priv' type of commands and ensured that the username had a password using the 'identified by ' syntax in the grant command. i could then use the system. Note that grant will not alter the rights of an existing user. I must say I don't remember trying the grant on an exisiting user while giving the 'identified by' clause. Anyhow, problem solved. It would be useful if these set-up steps and warnings were included in the on-line manuals relating to using the connections and grant system. Thanks for your input. It helped me find how to access the user info and led to the resolution.
[18 May 2006 20:41]
Valeriy Kravchuk
So, it is not a bug in MySQL server, if I got your idea right.

Description: I have a java application running on a Red Hat Linux server trying to connect to the localhost MySQL vesrion 4.1.10a database using the mysql-connector-java-3.1.12-bin.jar. The user name has been granted privelidges to select, insert and update the database and can connect fine on the command line. When the application trys to connect I get the following message: "Could not connect to the database java.sql.SQLException: Access denied for user 'trevor'@'localhost.localdomain' (using password: YES)" My java command is DriverManager.getConnection ("jdbc:mysql://localhost:3306/ullmanns?user=trevor&password=trevor"); I have tried all sorts of connections. The port is correct but even withoput setting the port it does the same. Please advise what I could be doing wrong or need to change. This is very urgent please. How to repeat: Create a database in the same environment settings and use a typical java connection to try the database.