Connecting from OS X 10.8 to MySQL I have a local network at home and am trying to develop some program. The program is cross-platform and it should connect to a MySQL server.

The server is set up on the Linux box and it accepts remote connections as I can successfully connect from Windows machines with Connector/C library. The server accepts connection on the standard port 3306.

However, when I try to connect from a Mac laptop (running OS X 10.8) to MySQL a connection is not established. I initially thought that this is due to the fact that my Mac does not display its host name/computer name in the router and therefore the network is confused. But even after applying what was suggested at this link, I still can't connect.

So now I'm wondering if OS X is running some kind of firewall where I need to unlock an outgoing port 3306 so that the connection will go through. Or there is some other thing that prevents the connection.

The port is open on the router, so there is no issues there.

So is there anything I can fix on the Mac side or at least check?



Edit:

I'm trying to connect using Connector/C from my program compiled with Xcode. An exact same code works fine from Windows (i.e. connection is established). All 3 machines are on the same home network. Calling mysql_error() does not produce any errors, but MYSQL pointer is NULL after calling mysql_real_connect().



Edit 2:

Here is what ifconfig shows:

MyMac:dbhandler igorkorot$ ifconfig
lo0: flags=8049&lt;UP,LOOPBACK,RUNNING,MULTICAST&gt; mtu 16384
    options=3&lt;RXCSUM,TXCSUM&gt;
    inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1 
    inet 127.0.0.1 netmask 0xff000000 
    inet6 ::1 prefixlen 128 
gif0: flags=8010&lt;POINTOPOINT,MULTICAST&gt; mtu 1280
stf0: flags=0&lt;&gt; mtu 1280
en0: flags=8863&lt;UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST&gt; mtu 1500
    ether b8:e8:56:21:e0:c0 
    inet6 fe80::bae8:56ff:fe21:e0c0%en0 prefixlen 64 scopeid 0x4 
    inet6 2601:140:4003:860:bae8:56ff:fe21:e0c0 prefixlen 64 autoconf 
    inet6 2601:140:4003:860:65c6:8063:98a:4650 prefixlen 64 autoconf temporary 
    inet6 2601:140:4003:860::1088 prefixlen 64 
    inet 192.168.1.3 netmask 0xffffff00 broadcast 192.168.1.255
    media: autoselect
    status: active
p2p0: flags=8843&lt;UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST&gt; mtu 2304
    ether 0a:e8:56:21:e0:c0 
    media: autoselect
    status: inactive


So opening Network Utility and trying to scan for 3300 - 3310 at 192.168.1.3 does not produce anything. It just says this:

Port Scan has started…

Port Scanning host: 192.168.1.3

Port Scan has completed…


Trying to scan the machine where MySQL is I get following:

Port Scan has started…

Port Scanning host: 192.168.1.2

     Open TCP Port:     3306        mysql
Port Scan has completed…
Step one is to ensure your ports are open and there isn’t a network issue. 

In the Finder, open /Applications/Utilities/Network Utility.app

Then choose "Port Scan". Enter the IP address (or the name if DNS is set up in your network) of the Linux Box and scan all ports less than 4000. 

A success would look like your results:

Port Scanning host: 192.168.1.2

     Open TCP Port:     3306        mysql
Port Scan has completed…


That should be a quick check that the network and/or DNS are working. It's almost certainly not being blocked - you have to do a lot of non-default work to block arbitrary outbound ports.

If not, you’ll need a follow on question with enough details for someone to help. 

If the network is working, you can be assured it’s not related to OS X and perhaps focus on a code level question on Stack Overflow.