无法使用 VB6 连接到远程 MySQL (10060)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12349948/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Cannot connect to remote MySQL with VB6 (10060)
提问by Berker Yüceer
I got a hosting plan from GKG.net and I have a VB6 connection string to remotely reach MySQL database in it. I followed all instructions and tutorials about how to reach MySQL server remotely. Everything was fine till i get an error that says:
我从 GKG.net 获得了一个托管计划,并且我有一个 VB6 连接字符串可以远程访问其中的 MySQL 数据库。我遵循了有关如何远程访问 MySQL 服务器的所有说明和教程。一切都很好,直到我收到一条错误消息:
[MySQL][ODBC 3.51 Driver] Can't connect to MySQL server on 'xxx.xxx.xxx.xxx' (10060)
[MySQL][ODBC 3.51 驱动程序] 'xxx.xxx.xxx.xxx' 上的 MySQL 服务器无法连接 (10060)
I searched for a solution over the net for hours but still there is nothing makes sense about it.. I double checked my connections.. I can ping to my static ip, but cant reach the MySQL server in it.
我在网上搜索了几个小时的解决方案,但仍然没有任何意义..我仔细检查了我的连接..我可以ping到我的静态IP,但无法访问其中的MySQL服务器。
From CPanel i can reach my db with phpMyAdmin. I tested my db and there was nothing wrong with it. Everything seems right. Except i still get the error message with VB6
从 CPanel 我可以使用 phpMyAdmin 访问我的数据库。我测试了我的数据库,没有任何问题。一切似乎都对。除了我仍然收到 VB6 的错误消息
My connection string:
我的连接字符串:
Dim conn As ADODB.Connection
Dim constr As String
Private Sub OpenServer()
Set conn = New ADODB.Connection
constr = "Driver={MySQL ODBC 3.51 Driver};" & _
"PORT=" & db_port & ";" & _
"SERVER=" & db_server & ";" & _
"DATABASE=" & db_name & ";" & _
"UID=" & db_user & ";" & _
"PWD=" & db_pass & ";" & _
"OPTION=3;" & _
"STMT=;"
conn.Open constr
End Sub
So how can i resolve this damned connection issue? and What are the odds that causes this?
那么我该如何解决这个该死的连接问题呢?导致这种情况的几率是多少?
回答by Zippit
Hosts where you access their database server very rarely allow remote access to the database from outside their hosting environment (I have never seen it).
您访问其数据库服务器的主机很少允许从其托管环境之外远程访问数据库(我从未见过)。
If you setup the MySql database yourself (on a dedicated or virtual server plan) then you should be able to set it up to accept remote hosts. In that case you need to modify your my.con file to allow remote hosts (you can also do it via the MySql Admin tools) and you need to grant the login you are trying to use access from the remote IP:
如果您自己设置 MySql 数据库(在专用或虚拟服务器计划上),那么您应该能够将其设置为接受远程主机。在这种情况下,您需要修改 my.con 文件以允许远程主机(您也可以通过 MySql 管理工具执行此操作),并且您需要授予您尝试使用远程 IP 访问权限的登录名:
http://www.cyberciti.biz/tips/how-do-i-enable-remote-access-to-mysql-database-server.html
http://www.cyberciti.biz/tips/how-do-i-enable-remote-access-to-mysql-database-server.html
Your previous comment about SQLyog is a very good idea. And I can vouch for that product. It is a great tool. The free admin tools from MySql (Workbench - http://www.mysql.com/downloads/workbench/) are also decent and will allow you to test remote access as well.
您之前对 SQLyog 的评论是一个非常好的主意。我可以担保那个产品。这是一个很棒的工具。MySql (Workbench - http://www.mysql.com/downloads/workbench/)的免费管理工具也很不错,可以让你测试远程访问。
回答by Sathish
check this Solution to Connecting remotely when you get Error 10060
当您收到错误 10060 时,请检查此远程连接解决方案
http://forums.mysql.com/read.php?34,49742,239961
http://forums.mysql.com/read.php?34,49742,239961
http://www.bigresource.com/VB-Remote-MySQL-Server-h6Z8Cbaszz.html#
http://www.bigresource.com/VB-Remote-MySQL-Server-h6Z8Cbaszz.html#
MySQL is setup to handle remote connections very easily. However, you must setup MySQL to allow your users in. The other thing to do, is make sure port 3306 is open on the host. If it is not, then you can't connect to MySQL. The easiest way to do this is to...
MySQL 设置为非常轻松地处理远程连接。但是,您必须设置 MySQL 以允许您的用户进入。另一件事是确保主机上的端口 3306 已打开。如果不是,则无法连接到 MySQL。做到这一点最简单的方法是...
telnet myhost 3306
远程登录我的主机 3306
If you get something back like... , 3.23.54-log?I_&:309i?
如果你得到类似... , 3.23.54-log?I_&:309i?
then port 3306 is open and MySQL is listening.
然后端口 3306 打开并且 MySQL 正在侦听。
Next, make sure your userid is setup to allow access on the MySQL server. You can do this with the mysql client software, or the mysqlcc software.
接下来,确保您的用户 ID 设置为允许访问 MySQL 服务器。您可以使用 mysql 客户端软件或 mysqlcc 软件执行此操作。
Hope this helps
希望这可以帮助
回答by Allan Vernon
I had this problem. I could connect from localhost but not from a client computer. I turned off Windows firewall (windows 8). However, no joy. I then created a new rule in firewall advanced settings and BINGO it worked. The new rule just allowed incoming connections on port 3306 on my private network.
我有这个问题。我可以从本地主机连接,但不能从客户端计算机连接。我关闭了 Windows 防火墙(Windows 8)。然而,没有喜悦。然后我在防火墙高级设置和 BINGO 中创建了一个新规则,它起作用了。新规则仅允许在我的专用网络上的端口 3306 上进行传入连接。
回答by Ray Erasmus
Another approach for VB6. I use it like this in all my apps and its been working for years.
VB6 的另一种方法。我在我所有的应用程序中都像这样使用它并且它已经工作了多年。
Dim StoreDB As ADODB.Connection
On Error Resume Next
Set StoreDB = New ADODB.Connection
StoreDB.Open "Driver={MySQL ODBC 3.51 Driver};Server=000.000.000.000;Port=3306;Database=yourDBName;User=Someusername;Password=Somepassword;OPTION=8;"
If Err.Number = 0 Then
[VB6 Code to execute]
Else
myErrorString = Err.Description
End If
StoreDB.Close
Set StoreDB = Nothing
Dim StoreDB 作为 ADODB.Connection
出错时继续下一步
设置 StoreDB = 新建 ADODB.Connection
StoreDB.Open "Driver={MySQL ODBC 3.51 Driver};Server=000.000.000.000;Port=3306;Database=yourDBName;User=Someusername;Password=Somepassword;OPTION=8;"
如果 Err.Number = 0 那么
【要执行的VB6代码】
别的
myErrorString = Err.Description
万一
存储数据库关闭
设置 StoreDB = 无
As mentioned, ensure port is 3306. I have a host that uses 3307. I see no problem with your code. You probably need to sort this with the host.
如前所述,确保端口为 3306。我有一台使用 3307 的主机。我认为您的代码没有问题。您可能需要与主机进行排序。
回答by Hisham Javed
Add mysqlid.exe into your windows firewall settings to access your server remotely
将 mysqlid.exe 添加到您的 Windows 防火墙设置中以远程访问您的服务器