Connecting Access to MySQL (1 Viewer)

Steve R.

Retired
Local time
Today, 18:14
Joined
Jul 5, 2006
Messages
4,617
This is a follow up to Connecting to MySQL

I was able to successfully connect Access on one computer to MYSQL on a second computer using LINUX (UBUNTU). I laid the project aside for a while since UBUNTU issued a new version 9.04.

An issue that I was attempting to resolve concerned how to create a static IP address for the LINUX computer. I wasn't able to do it. Anyway, I had one of those moments of inspiration while doing nothing where I came up with an alternative, to use the hostname of the LINUX computer. That was partially successful.

The code from the Access computer below works
Code:
Private Function ConnectString() As String
Rem Connect to MySQL MySQL MySQL MySQL MySQL
Rem ADOX ADOX ADOX ADOX ADOX ADOX ADOX ADOX
    Dim strServerName As String
    Dim strDataBaseName As String
    Dim strPassword As String
    Dim strUserName As String
    Rem strServerName = "192.168.1.102"
    strServerName = "steven-desktop"
    strDataBaseName = "world"
    strUserName = "steve"
    strPassword = "whatever"
    
    ConnectString = "Driver={mySQL ODBC 3.51 Driver};" & _
                    "Server=" & strServerName & _
                    ";DATABASE=" & strDataBaseName & ";" & _
                    "USER=" & strUserName & _
                    ";PASSWORD=" & strPassword & _
                    ";OPTION=3;"
End Function

On the LINUX computer the MY.CNF file has the following
Code:
bind-address		= 192.168.1.102
#bind-address		= steven-desktop

When I attempt to use the bind address using the host name "steven-desktop" instead of 192.168.1.102 to connect, it fails. Any additional thoughts?

One option, it I get ambitious, would be to pump ifconfig through grep, pick up the current ip address, replace it in the MY.CNF file.

Alternatively, I can go back to trying to figure out how to assign a static IP address. But that is not my question now.
 

Banana

split with a cherry atop.
Local time
Today, 15:14
Joined
Sep 1, 2005
Messages
6,318
Few things.

1) Bind-Address is an directive to the daemon to listen for only connection requests coming from that IP. Normally, it's used to restrict daemon to listen on a certain IP. It cannot be used to listen for a range of IP address or can it be used with a hostname.

2) You would normally configure the iptables to set up the rules (e.g. allow the port 3306 to be open to only 192.168.xxx.xxx and closed otherwise). This is much more flexible and efficient at controlling what clients can connect to the host. I don't know if Ubuntu comes with iptables or whether it uses its own version. I'd check and find out if iptables is included or what is the equivalent program used in Ubuntu.

3) You really shouldn't be rewriting the my.cnf everytime you connect just to get the IP right.
 

Steve R.

Retired
Local time
Today, 18:14
Joined
Jul 5, 2006
Messages
4,617
Thanks, for the educational reply, just what I need to follow-up on this.

I agree that it would not be a good idea to write to the my.cnf file every time the computer boots.

Thanks again for pointing me in the direction to look at the iptables.
 

Users who are viewing this thread

Top Bottom