Excel VBA connecting to remote MySQL database
I am using OBDC connector to use VBA to connect to my MySQL database. It is currently running on a local web server (localhost), but is accessible from other computers on the network using the computer's IP address.
In my connect function, I had it localhost
as location, but when I change it to my IP, I get
[MySQL][ODBC 5.2 Driver] (my computer name) is not allowed to connect to this MySQL server
mistake.
I assume this is a security issue. Any way to fix this?
Here is my join function:
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
0
source to share