You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by "Ozakca, Muzaffer" <mo...@indiana.edu> on 2008/04/18 23:15:48 UTC

Mysql and usernames

Hi,

I have an issue when I’m trying to connect to a Mysql database on a different machine than the one that runs my code. I get this exception:

java.sql.SQLException: Access denied for user 'user'@'%'

As you might know, Mysql users consist of a name and a location (or % for all locations). For example, you can define user@localhost to be a user. The user cannot login if s/he is not on “localhost”.

I’m running my code on machineA and the database is on machineB. The database user is defined as user@machineA. I can connect to the database using the normal mysql tools on machineA.

The login credentials are specified as

<login userName="user" password="xxx"/>

In the cayenne config file. My question is how can I tell cayenne to use a specific machine name (i.e. machine’s DNS name) instead of “%”

I hope I am clear.

Thanks,
Muzaffer


Re: Mysql and usernames

Posted by Aristedes Maniatis <ar...@ish.com.au>.
On 21/04/2008, at 10:47 AM, Kevin Menard wrote:
> It's been a while since I've used MySQL, but I think "%" is just a  
> wildcard meaning "any host."  Cayenne doesn't send the host  
> along . . . MySQL figures that part out when it receives the  
> connection.  You need to set up your own DNS appropriately.  Check  
> the MySQL logs to see what hostname MySQL thinks is being used.

Also important is that a user defined as user@% does not get used for  
a connection from user@localhost. For some reason localhost is treated  
separately from all other hosts and needs to be defined explicitly.

Ari


-------------------------->
ish
http://www.ish.com.au
Level 1, 30 Wilson Street Newtown 2042 Australia
phone +61 2 9550 5001   fax +61 2 9550 4001
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A



Re: Mysql and usernames

Posted by Kevin Menard <km...@servprise.com>.
It's been a while since I've used MySQL, but I think "%" is just a  
wildcard meaning "any host."  Cayenne doesn't send the host  
along . . . MySQL figures that part out when it receives the  
connection.  You need to set up your own DNS appropriately.  Check the  
MySQL logs to see what hostname MySQL thinks is being used.

-- 
Kevin

On Apr 18, 2008, at 5:15 PM, Ozakca, Muzaffer wrote:

> Hi,
>
> I have an issue when I’m trying to connect to a Mysql database on a  
> different machine than the one that runs my code. I get this  
> exception:
>
> java.sql.SQLException: Access denied for user 'user'@'%'
>
> As you might know, Mysql users consist of a name and a location (or  
> % for all locations). For example, you can define user@localhost to  
> be a user. The user cannot login if s/he is not on “localhost”.
>
> I’m running my code on machineA and the database is on machineB. The  
> database user is defined as user@machineA. I can connect to the  
> database using the normal mysql tools on machineA.
>
> The login credentials are specified as
>
> <login userName="user" password="xxx"/>
>
> In the cayenne config file. My question is how can I tell cayenne to  
> use a specific machine name (i.e. machine’s DNS name) instead of “%”
>
> I hope I am clear.
>
> Thanks,
> Muzaffer
>


RE: Mysql and usernames

Posted by "Ozakca, Muzaffer" <mo...@indiana.edu>.
Andrus and Kevin,

You were both right, it was some kind of reverse lookup issue on the Mysql side that prevents logging in. I was confused about that and adding the IP address to the Mysql user resolved the issue.

Thanks,
Muzaffer

> -----Original Message-----
> From: Andrus Adamchik [mailto:andrus@objectstyle.org]
> Sent: Sunday, April 20, 2008 6:21 AM
> To: user@cayenne.apache.org
> Subject: Re: Mysql and usernames
>
> It is not *cayenne* that denies access. It is MySQL server. So that's
> where you need to look. Check for instance that reverse DNS from
> machine B works for machine A, or enter machine A IP address in the
> access table.
>
> Andrus
>
>
> On Apr 19, 2008, at 12:15 AM, Ozakca, Muzaffer wrote:
> > Hi,
> >
> > I have an issue when I’m trying to connect to a Mysql database on a
> > different machine than the one that runs my code. I get this
> > exception:
> >
> > java.sql.SQLException: Access denied for user 'user'@'%'
> >
> > As you might know, Mysql users consist of a name and a location (or
> > % for all locations). For example, you can define user@localhost to
> > be a user. The user cannot login if s/he is not on “localhost”.
> >
> > I’m running my code on machineA and the database is on machineB. The
> > database user is defined as user@machineA. I can connect to the
> > database using the normal mysql tools on machineA.
> >
> > The login credentials are specified as
> >
> > <login userName="user" password="xxx"/>
> >
> > In the cayenne config file. My question is how can I tell cayenne to
> > use a specific machine name (i.e. machine’s DNS name) instead of “%”
> >
> > I hope I am clear.
> >
> > Thanks,
> > Muzaffer
> >


Re: Mysql and usernames

Posted by Andrus Adamchik <an...@objectstyle.org>.
It is not *cayenne* that denies access. It is MySQL server. So that's  
where you need to look. Check for instance that reverse DNS from  
machine B works for machine A, or enter machine A IP address in the  
access table.

Andrus


On Apr 19, 2008, at 12:15 AM, Ozakca, Muzaffer wrote:
> Hi,
>
> I have an issue when I’m trying to connect to a Mysql database on a  
> different machine than the one that runs my code. I get this  
> exception:
>
> java.sql.SQLException: Access denied for user 'user'@'%'
>
> As you might know, Mysql users consist of a name and a location (or  
> % for all locations). For example, you can define user@localhost to  
> be a user. The user cannot login if s/he is not on “localhost”.
>
> I’m running my code on machineA and the database is on machineB. The  
> database user is defined as user@machineA. I can connect to the  
> database using the normal mysql tools on machineA.
>
> The login credentials are specified as
>
> <login userName="user" password="xxx"/>
>
> In the cayenne config file. My question is how can I tell cayenne to  
> use a specific machine name (i.e. machine’s DNS name) instead of “%”
>
> I hope I am clear.
>
> Thanks,
> Muzaffer
>