• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem connecting to mysql through Jdbc

 
Ragav Seth
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Everyone,

Iam using mysql-4.1.11 on fedora 4.I have downloaded mysql-connector-java-3.1.10 and I have put the corresponding jar file in the jre\lib\ext folder.

when i run a sample Jdbc program for testing i use the following

Connection conn = DriverManager.getConnection("jdbc:mysql://192.168.1.251/mysql?","root","welcome");

when i run the program i get the following error

SQLException: null, message from server: "Host '192.168.1.251' is not allowed to connect to this MySQL server"
SQLState: HY000
VendorError: 1130

Can anyone please help me on this.??

Thanks
Ragav

"One who renounces his life for the sake of finding me shall find me"-Jesus Christ.

"Renunciation is the only way to perfection"-swami Vivekananda.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With Mysql, each 'login' also requires permission to connect from a location. ie you don't login to a user, you login to a 'user at a location'. By default the only user is root@localhost.

You need to login to MySQL and run the following:
grant all on <schema>.* to root@'192.168.1.251' identified by 'welcome';
(replace the <schema> part with the actual schema name)

You will have to run this for every IP that root logs in from. You can also use root@'%' to allow root to connect from anywhere, but this is not recommended.

Dave
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh, and without meaning to offend you, we prefer to limit the religious messages included in posts. I'm catholic myself and not offended, but this is a Java site and in the interests of keeping the peace it's better to ask certain elements to be omitted. Politics is another area we find ourselves getting into trouble

I hope you understand.

thanks,
Dave.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
and since I'm being verbose today, welcome to the JavaRanch!



Dave
 
Ragav Seth
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you.Your solution just worked fine.But do u mean to say I have to configure each and every IP that is trying to connect remotely.

Thanks
Ragav
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes, either that or allow a 'user' to connect from any IP using the wildcard. This should be used with caution though.
 
Ragav Seth
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry dave to get back to you again with this question.

How do I allow an user to connect from any IP using the wildcard option.

I will try to do some research on this myself but just in case if you have some ideas please pass it over.

Thanks
Ragav
 
Sunil Kumar Gupta
Ranch Hand
Posts: 824
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try this





>mysql -u root

>GRANT ALL PRIVILEGES ON *.* TO 'username'@'%'


where % is the wildcard used to connect from any IP


and see it works.

enjoy

 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You will have to run this for every IP that root logs in from. You can also use root@'%' to allow root to connect from anywhere, but this is not recommended.

I guess you missed that bit
schema.* is preferable to *.*, no point opening things up too much.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic