Connecting from OS X 10.8 to MySQL
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.