As I wrote in the topic, this works totally fine:
mysql_connect("server","username","password");
But this doesn't:
MySql.Data.MySqlClient.MySqlConnection connection =
new MySql.Data.MySqlClient.MySqlConnection("SERVER=server;DATABASE=database;UID=username;PASSWORD=password;");
connection.Open();
The exception is always
Unable to connect to any of the specified MySQL hosts
And no, the question is neither a duplicate, nor answered there
serverwithlocalhostPASSWORDshould bepwd. Better yet useMySqlConnectionStringBuilderso you don't have to worry about the details of the connection string, as per the answer in the question that I'm about to mark this a dupe of.