Bug #61237 Unable to connect to any of the specified hosts (on Mac only)
Submitted: 20 May 2011 3:01 Modified: 16 Jun 2011 4:34
Reporter: Christopher Thielen Email Updates:
Status: Not a Bug Impact on me:
None 
Category:Connector / NET Severity:S1 (Critical)
Version:Multiple, incl 6.3.6 and 6.4bzr OS:Mac OS X
Assigned to: Bogdan Degtyariov CPU Architecture:Any

[20 May 2011 3:01] Christopher Thielen
Description:
I have a simple connection test for Mono 2.10.2 + MySQL 5 (such as the one on the Mono HOWTO page) that merely attempts to open a connection. On Linux, this code works fine, but on the Mac (both Snow Leopard and Lion beta), I receive the error, "Unable to connect to any of the specified hosts." The InnerException is empty. Here's the readout:

Unhandled Exception: MySql.Data.MySqlClient.MySqlException: Unable to connect to any of the specified MySQL hosts.
  at MySql.Data.MySqlClient.NativeDriver.Open () [0x00000] in <filename unknown>:0 
  at MySql.Data.MySqlClient.Driver.Open () [0x00000] in <filename unknown>:0 
  at MySql.Data.MySqlClient.Driver.Create (MySql.Data.MySqlClient.MySqlConnectionStringBuilder settings) [0x00000] in <filename unknown>:0 
  at MySql.Data.MySqlClient.MySqlConnection.Open () [0x00000] in <filename unknown>:0

I am able to connect to this localhost MySQL mac using the MySQL CLI program and the Mac program "Querious", as well as PHP and other languages installed locally. I can also "telnet localhost 3306" to confirm MySQL is running and responding.

This is my connection string:
string connStr = "Server=127.0.0.1;Database=RightsManagement;User ID=root;Password=;Pooling=false;Connection Timeout=10;Protocol=socket;Port=3306;";

Curiously, I am not able to connect to a remote MySQL instance either (say, running on a Linux laptop on the local network) either.

What could be causing this?

How to repeat:
Merely running the example program.

Suggested fix:
Unknown.
[20 May 2011 15:29] Valeriy Kravchuk
Maybe you should not use

Protocol=socket

in connection string if you connect via TCP/IP and port 3306?
[20 May 2011 20:16] Christopher Thielen
Heh, that bit of the connection string shouldn't be there - it's from my earlier tests trying to get this to work _somehow_.

I took that out and still experience the same error, same backtrace, same empty InnerException.
[20 May 2011 20:20] Christopher Thielen
FYI, this is mysql-5.5.12-osx10.6-x86_64, with a copy of my sample program and the test assembly (compiled from bzr yesterday) is here: http://epiar.net/MySQLConnectionTest.tar.bz2 .

Again, that code/assembly works on Linux with a localhost MySQL as well.
[20 May 2011 20:58] Christopher Thielen
(Apologies for the fragmented comments)

This error also occurs after it spends a good 4-5 seconds attempting to connect (on the db.open() line).
[24 May 2011 6:25] Christopher Thielen
Is there anything I can do to help with this bug? Additional logs perhaps?
[24 May 2011 9:25] Bogdan Degtyariov
Hi Christopher,

This looks like the problem in MONO rather than Connector/NET because the same DLL file worked fine in Linux.

Please confirm that you used the NET & MONO Download package. Copying MySql.Data.Dll from Windows installation would be not correct because Connector/NET has few conditional preprocessor directives #if MONO/#if !MONO.
[24 May 2011 17:17] Christopher Thielen
Makes sense. Yes, I can confirm it works in Linux and that I used the correct download for Mono. I also built it off bzr with MonoDevelop and experienced the same results. I'll file a bug on their side. Thanks!
[16 Jun 2011 4:34] Bogdan Degtyariov
Closed with "not a bug" status. The bug is in Mono.