简体   繁体   English

如何使用Java访问我的计算机(相距50公里)中的另一台计算机mysql数据库

[英]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.

相关问题 如何使用java和jdbc和sql成功访问另一台计算机上的数据库? - How to successfully access the database on another computer using java and jdbc and sql? 如何远程访问我计算机上的 MySQL 数据库? - How to get remote access to a MySQL database on my computer? 如何使用Java编程连接客户端计算机以使用安装在服务器计算机中的Sqlite数据库? - how to connect client computer to use Sqlite database which is installed in the server computer using java programming? 如何将带有数据库的 java 应用程序打开到另一台计算机 - How to open the java application with database to another computer 如何在另一台计算机上使用java mysql程序 - How to use java mysql program on another computer 如何将连接到 SQL 管理服务器数据库的 java NetBeans 项目转移到另一台计算机? - How can I transfer my java NetBeans project connected to SQL management server database to another computer? 从另一台计算机访问mysql数据库服务器? - Accessing mysql database server from another computer? Java嵌入式数据库,很少需要计算机访问 - Java Embedded Database For a Few Computer Access 如何将我的 java 程序复制到另一台计算机? - How can I copy my java program to another computer? Java、MySql——从另一台计算机连接 - Java, MySql -- connecting from another computer
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM