Unable to connect to any of the specified MySQL hosts RRS feed

  • Question

  • User-1379762086 posted

    I hosted a web api on a windows server that is to connect to mysql database server hosted in another server. The windows server has been give perimission to access the database and i was also able to connect the remote database using a workbench on the windows server but if my c# api application trys to access the remote database i get the below error...

    "Unable to connect to any of the specified MySQL hosts.
    stacktrace at MySql.Data.MySqlClient.NativeDriver.Open()\r\n at MySql.Data.MySqlClient.Driver.Open()\r\n
    at MySql.Data.MySqlClient.Driver.Create(MySqlConnectionStringBuilder settings)\r\n
    at MySql.Data.MySqlClient.MySqlPool.CreateNewPooledConnection()\r\n at MySql.Data.MySqlClient.MySqlPool.GetPooledConnection()\r\n
    at MySql.Data.MySqlClient.MySqlPool.TryToGetDriver()\r\n
    at MySql.Data.MySqlClient.MySqlPool.GetConnection()\r\n at MySql.Data.MySqlClient.MySqlConnection.Open()\r\n
    at SMSMobileApp.Controllers.SecondaryResultController.FetchCollegeResult(String sessionname, Int32 termid, String regno) in C:\\Users\\OLUWASEUN\\Documents\\Visual Studio 2017\\Projects\\SMSMobileApp\\SMSMobileApp\\Controllers\\SecondaryResultController.cs:line 79"


    <add name="smsresult" connectionString="Data Source=166.63.122.xx;port=3306;Initial Catalog=databasename;User Id=mydatabaseID;password=mypassword" />

    Please i need help ...........................

    Sunday, January 21, 2018 7:56 PM

All replies

  • User-1379762086 posted

    please i still need help on this

    Thursday, January 25, 2018 12:39 PM
  • User269602965 posted

    Could be firewall issue with the port.

    Remove the port variable from the connection string.

    Sometimes there are non-printable characters in the connection string... you do not see on the screen, but they are there.

    Erase and retype the connection string.

    Thursday, January 25, 2018 8:20 PM
  • User-1379762086 posted

    Thank you Lannie, i removed the port vairable but still unable to connect. Remember i was able to connect to the same database using work bench from same server where this application is failing to connect to the database.

    Saturday, January 27, 2018 8:46 PM
  • User269602965 posted

    Your thick client workbench app might be able to connect, but your WEB APP is going through a WEB SERVER layer like IIS 8.0 AND using an SQL client DLL.  Two different situations on the same server.

    One thing I do to reduce the problems in my application environment is I put my SQL client DLL in my web application BIN/ folder of the web app and make a local reference to the DLL, bypassing GAC and other factors like folder permissions external to your web application.

    Sunday, January 28, 2018 12:11 AM
  • User-1379762086 posted

    Thank you Lannie, I have done that but to no avail, please still need help on this

    Monday, February 12, 2018 10:46 AM
  • User269602965 posted

    Next it could be BITNESS issue.

    Is the server 64-bit and the driver 32-bit?

    if so, IIS will need to be configured to run 32-bit and the app will need compiled as 32-bit.

    Monday, February 12, 2018 5:26 PM