0

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!

5
  • Are you able to access remote MySql from Workbench? Commented Sep 12, 2014 at 17:52
  • Yes I can, the problem is only for the application. Commented Sep 12, 2014 at 17:54
  • You can grant a permission to user to connect from anywhere. Commented Sep 12, 2014 at 17:55
  • See this: stackoverflow.com/questions/14779104/… That shouldn't happen, if you're able to access remotely from Workbench you should be able to access from Java. Commented Sep 12, 2014 at 17:56
  • what exception is being thrown in your app? Commented Sep 12, 2014 at 19:04

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.