locked
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"

    BELOW IS CONNECTION STRING

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

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

    Thursday, January 25, 2018 12:41 PM

All replies

  • User-492460945 posted

    Hi abfrank,

    Did you check the connection using connection string like..

    Data Source=166.63.122.xx,3306;Initial Catalog=databasename;User Id=mydatabaseID;password=mypassword

    -Rajesh

    Friday, March 23, 2018 1:01 PM
  • User-1379762086 posted

    this is what i used

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

    Friday, March 23, 2018 1:12 PM
  • User475983607 posted

    this is what i used

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

    We have no idea what your connection string should be. Contact the MySQL or network admin for assistance.  

    Also see the MySQL support documentation which has examples for making a connection to MySQL from ASP.NET.

    https://dev.mysql.com/doc/connector-net/en/connector-net-programming-connecting-connection-string.html

    Friday, March 23, 2018 1:30 PM