I have an java app that connects to a database. I have some computers connected in the same router and one of them is supposed to be the server. So in its localhost I created the database with the tables. Let's say that the db is in A, with IP 192.168.0.a and the app is in computer B with IP 192.168.0.b! To access the db from B I must do something like this jdbc:mysql://192.168.0.a:3306/dbName
, but if I do not add a user in database with host 192.168.0.b
, the app will not work. So the question is: Is there a way to tell the database to accept request from all computers without adding users manually?
Thanks in advance!
Asked
Active
Viewed 181 times
0

Dionis Beqiraj
- 737
- 1
- 8
- 31
-
Are you able to access remote MySql from Workbench? – Pradeep Simha Sep 12 '14 at 17:52
-
Yes I can, the problem is only for the application. – Dionis Beqiraj Sep 12 '14 at 17:54
-
You can grant a permission to user to connect from anywhere. – Aleksandr M Sep 12 '14 at 17:55
-
See this: http://stackoverflow.com/questions/14779104/how-to-allow-remote-connection-to-mysql That shouldn't happen, if you're able to access remotely from Workbench you should be able to access from Java. – Pradeep Simha Sep 12 '14 at 17:56
-
what exception is being thrown in your app? – Dave Sep 12 '14 at 19:04
1 Answers
1
MySQL uses %
as a wildcard, so for "any host", it's enough to create an user with %
as host:
CREATE USER 'user'@'%' IDENTIFIED BY 'somepassword';
Also, after this you'll need to grant the user 'user'@'%'
rights to any databases it might need.

esaj
- 15,875
- 5
- 38
- 52