I am making an application that connects to remote mysql database into some cpanel account. I created the database on the cpanel account and defined a username and password for it. I am using MysqlConnector. So far I have written the following code:
using MySql.Data.MySqlClient;
MySqlConnection c = new MySqlConnection("SERVER = 64.191.12.54; DATABASE = alyataco_test4application; User ID = xxxxxxxx; PASSWORD = xxxxxxxx");
c.Open();
but i got error :
MySql.Data.MySqlClient.MySqlException: Unable to connect to any of the specified MySQL hosts.
i also saw Connect to remote MySQL database with Visual C# but didn`t help too
Your connection string seems wrong. Try:
MySqlConnection c = new MySqlConnection("server=64.191.12.54; database=alyataco_test4application; uid=xxxxxxxx; pwd=xxxxxxxx");
See http://www.connectionstrings.com/mysql for more connection string exemples.
Chances are your host does not allow remote connections to the database server. Easy way to tell is if you deploy your project to the server and it works.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With