I am attempting to make a simple connection to a MySql database, located on another machine. I can telnet to the data source on Windows and using the terminal on OSX and Ubuntu — both internal and externally to my network. It however refuses to connect via my mono project on OSX.
I receive:
Unable to connect to any of the specified MySQL hosts…
I have confirmed there are no firewall rules in effect — neither on my OSX or Ubuntu machines, where the database is hosted. MySQL workbench, which is on the same machine as the mono project, is able to connect without an issue.
I have attempted to connect to the database through code:
Server=myIp; Database=FK; User
ID=george; Password=pass; Port=3306
and through the plugin which comes pre-installed in Mono on OSX:
Tools > Database > Add Database Connection > MySql database
I don’t use my connection string — I let it create it’s own based on my database information. However, it doesn’t make a difference. When I test my connection — it still fails with the same message I receive when I attempt to connect programatically.
The server hosting the mySQL database shows no connection attempts.
I have attempted to use both the 5.2 mono .NET connector and 6.3 connectors (both v2 and v4) It doesn’t matter, both fail to connect.
I have tried placing my assemblies in the GAC and locally to my project in the bin directory. It doesn’t make a difference.
I have tried both socket and tcp, as well as memory and pipe, in the connection protocol. None work.
It makes absolutely no sense to me why I cannot get a connect to my server, where it works everywhere else, except from within Mono. There are no firewalls running that would be blocking my requests.
It shouldn’t be this difficult to connect from Mono, so something is obviously very wrong somewhere — seeing that the IDE can’t even connect to the database.
My credentials are absolutely correct, even though it doesn’t matter — as I can’t even hit the server. I would assume that it’s attempting to connect, as it takes around 10-15 seconds to receive a response saying that it was unable to connect.
The same exact code connects fine when deployed to my Ubuntu server (located on a seperate machine and network as the mySQL server), which is serving it up through mono and apache. Could it be an XSP problem? I have no idea.
I have spent countless hours trying to get this to work, going through every tutorial and website I could find about connecting to mySQL from mono. Every one has concluded the same way as the last, failure. Any help?
Here’s what I did to get it to connect.
Replace the
CreateSocketStreammethod ofStreamCreator.cs(see in code comments)Obviously this is ugly and a hack. However, I have found no other way, except what I commented above to get OSX + Mono to connect. It simply won’t work without these changes.