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...
<div>
"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"
Member
6 Points
96 Posts
Unable to connect to any of the specified MySQL hosts
Jan 25, 2018 12:41 PM|abfrank|LINK
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...
<div>"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 ...........................
</div> </div>Participant
1644 Points
792 Posts
Re: Unable to connect to any of the specified MySQL hosts
Mar 23, 2018 01:01 PM|rajesh93180|LINK
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
Mark as answer if you find this post helpful.
Member
6 Points
96 Posts
Re: Unable to connect to any of the specified MySQL hosts
Mar 23, 2018 01:12 PM|abfrank|LINK
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" />
All-Star
53641 Points
24004 Posts
Re: Unable to connect to any of the specified MySQL hosts
Mar 23, 2018 01:30 PM|mgebhard|LINK
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