我有兩臺工作計算機,在同一個網絡上,相同的公共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