0

My Friend needs to access my MySQL database remotely using his java program,he has completed all coding but wen we try to connect with IP and correct user name,password,i have disabled my firewall and enabled dmz in my router to open all ports,Still wen tries to communicate,its says communication link failure,there is no permission to access this mysql server.

This is the error:

java.sql.SQLException: null,  message from server: "Host 
            '45.123.3.250' is not allowed to connect to this MySQL server"
ρяσѕρєя K
  • 132,198
  • 53
  • 198
  • 213
  • Try GRANTing permission for your friend to connect from his IP address: http://stackoverflow.com/questions/6239131/how-to-grant-remote-access-permissions-to-mysql-server-for-user – duffymo Jan 06 '17 at 02:10
  • 1
    this is about network problem. probably, you try to build a simple helloworld page and set your computer to become a server. Then, try to ask your friend to open that page you had setup. You need to configure till your friend can access and your purpose of this question will complete – Kasnady Jan 06 '17 at 02:11
  • see http://stackoverflow.com/q/5016505/2310289 – Scary Wombat Jan 06 '17 at 02:12
  • 1
    Off topic: think really, really, *really* hard before directly exposing an SQL database to the Internet. Doing this has lead to truly epic Tales of Fail. – user4581301 Jan 06 '17 at 02:19
  • Is `45.123.3.250` the IP Address of your computer or the IP Address of your router? If routers IP Address, did you configure router to NAT to your computer? Your computers IP is likely an internal IP like `192.168.x.x`, and cannot be access from outside without NAT'ing configured on the router. – Andreas Jan 06 '17 at 02:24
  • We have a database of information,my freind javaprogram must access it,so should i bring my databse to his computer and access locally?ur saying – user7382013 Jan 06 '17 at 02:26
  • Its public ip of my freind computer(45...),he had tried to connect with my public ip which is 50. Something – user7382013 Jan 06 '17 at 02:28
  • imaging 'java' on screen = 1cm, if you write 'java' 5,000,000 times, it will reach 50km :) – SIDU Jan 06 '17 at 04:44
  • Possible duplicate of [Connect Java to a MySQL database](http://stackoverflow.com/questions/2839321/connect-java-to-a-mysql-database) – David Rawson Jan 06 '17 at 06:03
  • Execute the `GRANT` command and then execute `flush privileges`. This should give access. On the security side, you can use `mysqldump` to take a dump of the data and then load it in your friends mysql server. – prajeesh kumar Jan 06 '17 at 07:16

1 Answers1

1

The error you received is indication that MySql is blocking the connection.

MySql by default will not allow one to connect from a remote machine. You must explicitly grant access for your friend to connect remotely.

Typically you would grant to a user@hostname, but you may substitute % for hostname. The downside of this is that it would open it up for anyone using the username (and the password you specify) to connect from anywhere, but eliminates the issues around dynamic IP addressing or NATed networks.

For more information see MySql documentation on access control and GRANT command.

Jason Blue
  • 11
  • 1