我有两台工作计算机,在同一个网络上,相同的公共IP。我能够从计算机1的本地主机上成功连接到mySQL数据库。我试图通过Excel VBA从计算机2连接到同一数据库。我试过连接错误:Excel VBA到远程MySQL
mysql> GRANT ALL PRIVILEGES ON database.* to [email protected]'ip' IDENTIFIED BY 'pass'
mysql> GRANT ALL PRIVILEGES ON database.* to [email protected]'%' IDENTIFIED BY 'pass'
Excel的VBA:
Dim strServer As String
Dim strDBName As String
Dim strUserID As String
Dim strPasswd As String
strServer = "ipaddress"
strDBName = "dbname"
strUserID = "userid"
strPasswd = "pass"
Set oConn = New ADODB.Connection
With oConn
.ConnectionString = "Driver={MySQL ODBC 5.2 Unicode Driver};" & _
"Server=" & strServer & ";Port=3306;" & _
"Database=" & strDBName & ";" & _
"Uid=" & strUserID & ";" & _
"Pwd=" & strPasswd & ";Option=3;"
.Open
End With
MsgBox "Connection Successful"
Excel的VBA错误:
"Run-time error '-2147467259 (800004005)': [MySQL][ODBC 5.2(w) Driver]Can't connect to MySQL server on 'ip' (10061)"
是我的语法关的地方,还是我失去了一些东西? (我还有3台其他工作计算机,在不同的网络上,我想授予类似的权限,因为它们都使用共享的Excel工作簿)。
嗨,哥们,我面对完全相同的问题,你解决了吗? – b1919676 2016-11-11 15:08:39