Skip to main content

Tomcat Connections

Problem:

An apache Tomcat application could not connect to the mysql database. The user was defined as username@localhost.

The error displayed was:

"#HY000Host 'localhost.localdomain' is not allowed to connect to this MySQL server"
Solution:

Ensure that in /etc/hosts, the localhost name is in as:

127.0.0.1  localhost localhost.localdomain

The resolver picks the first match; if the entry for localhost has localhost.localdomain as the first name associated with the IP address, then this is the name returned during reverse lookups. So you must either fix things so that the short name is first, or redefine all your users to be username@localhost.localdomain.