Unable to connect to any of the specified MySQL hosts
I get an MySqlException: "Unable to connect to any of the specified MySQL hosts" after deploying an ASP.NET Core webapp in IIS. My connection string is: Server=mysql9.mijnhostingpartner.nl;Database=Gouw1vveflorijn;user=;password=
Is there something I forget?
In some of the ways, spacing and the order of parameters in the MySql connection string does matters. So, stick to the standard format:
MysqlConn.ConnectionString = "Server=localhost;Port=1234;Database=My_Mysql_Database;Uid=root;Pwd=root;"
If the above connection string fails, try update your c# mysql connection string as shown below (without port variable as well):
MysqlConn.ConnectionString = "Server=localhost;Database=My_Mysql_Database;Uid=root;Pwd=root;"
Or, sometime the problem could be on your windows firewall, make sure your server allow access to all port associated with your mysql database.