vba 远程mysql_Excel VBA连接到远程MySQL数据库

我正在使用OBDC连接器来使用VBA连接到我的MySQL数据库。它目前运行在本地网络服务器(本地主机)上,但可通过我的PC的IP地址从网络上的其他PC访问。Excel VBA连接到远程MySQL数据库

在我的连接功能,我有localhost的位置,但是当我将其更改为我的IP地址,我得到一个

[MySQL][ODBC 5.2 Driver] (my computer name) is not allowed to connect to this MySQL server

错误。

我认为这是一个安全问题。有任何解决这个问题的方法吗?

这里是我的连接功能:

Public Function OpenConnection() As ADODB.connection

//This function requires the "Microsoft ActiveX Data Objects" Library (Choose v2.8 from references for compatibility across Office versions)

Dim source As String, location As String, user As String, password As String

source = "MySQL"

location = "192.168.1.60"

user = "root"

password = ""

database = "database name"

mysql_driver = "MySQL ODBC 5.2 ANSI Driver"

//Build the connection string

Dim connectionString As String

connectionString = "Driver={" & mysql_driver & "};Server=" & location & ";Database=" & database & ";UID=" & user & ";PWD=" & password

//Create and open a new connection to the selected source

Set OpenConnection = New ADODB.connection

OpenConnection.CursorLocation = adUseClient

Call OpenConnection.Open(connectionString)

End Function

2013-10-18

harryg

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值