[英]How to access another computer mysql database in my computer(which is 50km away)using java
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. 我的朋友需要使用他的java程序远程访问我的MySQL数据库,他已经完成了所有编码,但是我们尝试使用IP连接并正确输入用户名,密码,所以我禁用了防火墙,并在路由器中启用了dmz来打开所有端口,仍在尝试通信,它说通信链接失败,没有访问此mysql服务器的权限。
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"
The error you received is indication that MySql is blocking the connection. 您收到的错误表明MySql正在阻止连接。
MySql by default will not allow one to connect from a remote machine. 默认情况下,MySql不允许从远程计算机进行连接。 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. 通常,您将授予user @ 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.
这样做的缺点是它将为使用用户名(和您指定的密码)的任何人打开它,以便从任何地方进行连接,但消除了动态IP寻址或NATed网络周围的问题。
For more information see MySql documentation on access control and GRANT command. 有关更多信息,请参见有关访问控制和GRANT命令的MySql文档。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.