Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5934845
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:10:15+00:00 2026-05-22T15:10:15+00:00

I am attempting to make a simple connection to a MySql database, located on

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T15:10:16+00:00Added an answer on May 22, 2026 at 3:10 pm

    Here’s what I did to get it to connect.

    1. Download the source code for the MySql.Data adapter.
    2. Replace the CreateSocketStream method of StreamCreator.cs (see in code comments)

       private Stream CreateSocketStream(IPAddress ip, bool unix)
          {
              EndPoint endPoint;
      
              // You don't need the following lines.
              //if (!Platform.IsWindows() && unix)
              //  endPoint = CreateUnixEndPoint(hostList);
              //else
      
              // Instead create a regular IPEndPoint.
              endPoint = new IPEndPoint(ip, (int)port);
              // Replace the socket it is trying to use with the following.
              Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
              if (keepalive > 0)
              {
                  SetKeepAlive(socket, keepalive);
              }
               // Remove the async.  connection.  This hangs and fails.  Not sure why.
              //IAsyncResult ias = socket.BeginConnect(endPoint, null, null);
              //if (!ias.AsyncWaitHandle.WaitOne((int)timeOut * 1000, false))
              //{
              //  socket.Close();
              //  return null;
              //}
              try {
                  // Instead do a regular blocking connect to the endpoint.
                  socket.Connect(endPoint);
              } catch (Exception ex) {
                  throw;
              }
      
              // No longer relevant.
              //try
              //{
              //  socket.EndConnect(ias);
              //}
              //catch (Exception)
              //{
              //  socket.Close();
              //    throw;
              //}
              MyNetworkStream stream = new MyNetworkStream(socket, true);
              GC.SuppressFinalize(socket);
              GC.SuppressFinalize(stream);
              return stream;
          }
      

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am attempting to make a simple connection to a remote database. I can
When attempting to open a project from source control on a newly formatted pc,
I am trying to make a simple Client-Server application but when I execute the
I am attempting to write a simple WPF learning project which creates a set
I am attempting to pull some information from my tnsnames file using regex. I
Attempting to insert an escape character into a table results in a warning. For
Attempting to print out a list of values from 2 different variables that are
Attempting to deploy a MOSS solution to a UAT server from dev server for
When attempting to compile my C# project, I get the following error: 'C:\Documents and
When attempting to call functions in math.h , I'm getting link errors like the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.