1

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<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
    options=3<RXCSUM,TXCSUM>
    inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1 
    inet 127.0.0.1 netmask 0xff000000 
    inet6 ::1 prefixlen 128 
gif0: flags=8010<POINTOPOINT,MULTICAST> mtu 1280
stf0: flags=0<> mtu 1280
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> 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<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> 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…
  • Without much more information about your network setup (e.g. are the Mac and the machine running mySQL in the same LAN), the way you attempt to connect and the error messages you get it's hard to propose any fixes. Can you please edit your question accordingly? – nohillside Jun 25 '17 at 17:33
  • why not use network utility to port scan the database IP? If you see port 3306 open from macOS you know it’s not firewall or network related at all. – bmike Jun 25 '17 at 17:39
  • @patrix, question edited. Sorry about that. – Igor Jun 25 '17 at 18:00
  • @bmike, is one installed by default on OSX? I'm a developer, not a network admin. – Igor Jun 25 '17 at 18:03
  • Spotlight will show you the location. You have terminal app in utilities as well. Lots of thing you can do as a local user even if your account isn’t an admin user. – bmike Jun 25 '17 at 18:20
1

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.

  • @ bmike♦ question edited with more info. – Igor Jun 25 '17 at 19:50
  • @Igor - Excellent edit - I confirmed you don't have any issue on the Apple OS side - your ports are open so this purely is a code issue with your calls / library / mysql installation. Looks like you're most familiar with shells - so you can probably connect mysql client from the command line and convince yourself the same. – bmike Jun 25 '17 at 23:31
  • ♦, thank you. I was worried since the same code connects perfectly from Windowsand since I'm not really familiar with OSX internals... So now I will move to code check. – Igor Jun 26 '17 at 13:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .