You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by marju jalloh <ja...@yahoo.com> on 2006/01/05 13:33:53 UTC

erro jdbc connection with mysql

Hi everyone,

I`m trying to connect to mysql from jdbc but I freequently get this errror

 "...java.sql.SQLException: Data source rejected establishment of connection,  message from server: "Host 'localhost.localdomain' is not allowed to connect to this MySQL server..."

env
linux debian(serge)
jdbc driver
tomcat 4.1.*

can anyone tell me what causes the error and possible solution
Thanks in advance
mysql 4.0.24


			
---------------------------------
Yahoo! Photos
 Ring in the New Year with Photo Calendars. Add photos, events, holidays, whatever.

Re: erro jdbc connection with mysql

Posted by Rafal Zawadzki <ra...@eo.pl>.
> GRANT ALL PRIVILEGES on yourdatabase.* TO 'youruser'@'yourhostnametomcat'
> IDENTIFIED BY 'yourl33tpassword';

Oh, I forgot. After this you should:

FLUSH PRIVILEGES;

-- 
Rafał Zawadzki
Deploy/Release Manager
eo Networks Sp. z o.o.

Re: erro jdbc connection with mysql

Posted by Rafal Zawadzki <ra...@eo.pl>.
### marju jalloh <ja...@yahoo.com> wrote message to Tomcat Users List 
<us...@tomcat.apache.org> ###
### this is reply for: erro jdbc connection with mysql ###
> Hi everyone,
>
> I`m trying to connect to mysql from jdbc but I freequently get this errror
>
>  "...java.sql.SQLException: Data source rejected establishment of
> connection,  message from server: "Host 'localhost.localdomain' is not
> allowed to connect to this MySQL server..."

you have to use GRANT command (mysql).

for example:

GRANT ALL PRIVILEGES on yourdatabase.* TO 'youruser'@'yourhostnametomcat' 
IDENTIFIED BY 'yourl33tpassword';

bluszcz

-- 
Rafał Zawadzki
Deploy/Release Manager
eo Networks Sp. z o.o.

Re: erro jdbc connection with mysql

Posted by Bjørge Solli <bj...@nersc.no>.
On Thursday 05 January 2006 13:57, Rafal Zawadzki wrote:
> > In short, run this as root inside mysql:
> > GRANT ALL PRIVILEGES ON your_db_name.* TO
> > 'your_mysql_user'@'your_client_host' IDENTIFIED BY 'your_password';
>
> FLUSH ...

Not necessary when using GRANT, only necessary if you edit the 
privilege-tables by hand.

-- 
Bjørge Solli - Office:+47 55205847 cellph.:+47 91614343
Nansen Environmental and Remote Sensing Center - Bergen, Norway
http://www.nersc.no Reception: +47 55205800
Dept.: Mohn-Sverdrup Center for Global Ocean Studies 
       and Operational Oceanography

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: erro jdbc connection with mysql

Posted by Bjørge Solli <bj...@nersc.no>.
On Thursday 05 January 2006 15:42, marju jalloh wrote:
>> Rafal Zawadzki <rafal.zawadzki@eo.pl
>> > Bjørge Solli wrote: > In short, run this as root inside mysql: 
>> > GRANT ALL PRIVILEGES ON your_db_name.* TO
>> > 'your_mysql_user'@'your_client_host' IDENTIFIED BY 'your_password';
>>
>> FLUSH ...
> I made it thanks to Rafal Zawadzki and Bjørge Solli
> The solution was to grant permision to hostname and not localhost of ip
> address

Which hostname your mysql-client identifies itself coming from depends on the 
interface it uses to connect to it.

if you use
mysql -h localhost .. 
it uses the loopback interface and should identify itself as 
localhost.localdomain or just localhost or localhost.yourdomain.com, 
depending on your OS setup.
and if you use
mysql -h myhost.example.com .. 
or
mysql -h <ip> ..
it could use the external interface (depending on your OS), and hence identify 
itself with the hostname/ip even though you are working on the host itself.

So, depending on your OS it could work to just change the -h flag or 
equivalent, but now you fixed it anyway. FYIO.

> Once more thanks

np, but please answer *under* the text you are answering to avoid confusion 
hereafter, ref. the discussion "[OT] Top posting" Tuesday 17:35 (and the 
"question" thread on the same day).

-- 
Bjørge Solli - Office:+47 55205847 cellph.:+47 91614343
Nansen Environmental and Remote Sensing Center - Bergen, Norway
http://www.nersc.no Reception: +47 55205800
Dept.: Mohn-Sverdrup Center for Global Ocean Studies 
       and Operational Oceanography

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: erro jdbc connection with mysql

Posted by marju jalloh <ja...@yahoo.com>.
I made it thanks to Rafal Zawadzki and Bjørge Solli 
The solution was to grant permision to hostname and not localhost of ip address 

Once more thanks
Rafal Zawadzki <ra...@eo.pl> wrote: > In short, run this as root inside mysql:
> GRANT ALL PRIVILEGES ON your_db_name.* TO
> 'your_mysql_user'@'your_client_host' IDENTIFIED BY 'your_password';

FLUSH ...

-- 
Rafał Zawadzki
Deploy/Release Manager
eo Networks Sp. z o.o.



		
---------------------------------
 Yahoo! DSL Something to write home about. Just $16.99/mo. or less

Re: erro jdbc connection with mysql

Posted by Rafal Zawadzki <ra...@eo.pl>.
> In short, run this as root inside mysql:
> GRANT ALL PRIVILEGES ON your_db_name.* TO
> 'your_mysql_user'@'your_client_host' IDENTIFIED BY 'your_password';

FLUSH ...

-- 
Rafał Zawadzki
Deploy/Release Manager
eo Networks Sp. z o.o.

Re: erro jdbc connection with mysql

Posted by Bjørge Solli <bj...@nersc.no>.
On Thursday 05 January 2006 13:33, marju jalloh wrote:
>  "...java.sql.SQLException: Data source rejected establishment of
> connection,  message from server: "Host 'localhost.localdomain' is not
> allowed to connect to this MySQL server..."

This is an "error" in your mysql privileges. Read up on it on mysql in the 
doc: 
http://dev.mysql.com/doc/refman/4.1/en/database-use.html
http://dev.mysql.com/doc/refman/4.1/en/grant.html

In short, run this as root inside mysql:
GRANT ALL PRIVILEGES ON your_db_name.* TO 'your_mysql_user'@'your_client_host' 
IDENTIFIED BY 'your_password';

-- 
Bjørge Solli - Office:+47 55205847 cellph.:+47 91614343
Nansen Environmental and Remote Sensing Center - Bergen, Norway
http://www.nersc.no Reception: +47 55205800
Dept.: Mohn-Sverdrup Center for Global Ocean Studies 
       and Operational Oceanography

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org