Tomcat, MySQL and Redhat connection problem
Posted by: Marco Marlia
Date: November 29, 2004 05:23AM

We have a problem in connection between Tomcat and MySQL.

Here is an example log:
-----------------------
Attempted reconnect 3 times. Giving up.
Nov 27, 2004 4:44:45 PM org.apache.jk.server.JkCoyoteHandler action
INFO: RESET
DBCP borrowObject failed: java.sql.SQLException: Server connection failure during transaction. Due to underlying exception: 'java.sql.SQLException: Invalid authorization specification message from server: "Access denied for user: 'example@localhost.localdomain' (Using password: YES)"'.
-----------------------

What is strange is that we can easly connect to MySQL from the shell and from PhpMyAdmin. This happens with all the web application (but the same webapps work on the old server).

We are quite sure that the problem is not to be related to Tomcat but to Redhat local loopback name (not localhost but localhost.localdomain).

We are not able to log in mysqld (with mysql client) using:
mysql -u <user> -p<pwd> -h 127.0.0.1 <database>

and the error is:
ERROR 1045: Access denied for user: 'example@localhost.localdomain' (Using password: YES)

The ConnectorJ docs says:
Be aware
that RedHat Linux is broken with respect to the hostname portion for the case when you are connecting from
localhost. You need to use "localhost.localdomain" for the [hostname] value in this case. Follow this by issuing
the "FLUSH PRIVILEGES" command.

We done this on sticktoy user _without_ any result
GRANT ALL PRIVILEGES ON .* to 'example'@'localhost.localdomain' identified by '<the password>';
FLUSH PRIVILEGES;

I also changed in /etc/hosts from:
120.0.0.1 localhost.localdomain localhost
to:
120.0.0.1 localhost localhost.localdomain

with any change.

At the end I done this (for only one domain):
GRANT ALL PRIVILEGES ON .* to 'example'@'127.0.0.1' identified by '<the password>';
FLUSH PRIVILEGES;

And it works fine.

So now we have 2 issues:
- why mysql doesn't works with host=localhost.localdomain ?
- why it dows work with phpmyadmin or other php applications?

Thanks,

Marco

Options: ReplyQuote


Subject
Written By
Posted
Tomcat, MySQL and Redhat connection problem
November 29, 2004 05:23AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.