I'm working with the gitpod online IDE ( vs code in the browser with an ubuntu linux server behind it). I'm struggling with creating a Connection to my mysql database on an other linux (CentOS) server. I've set the Remote MySql hosts on the db server to '%' => 'all allowed'.
I'm using the MySql Connector package: https://www.nuget.org/packages/MySqlConnector to connect to it. That's what my code looks like:
public async Task<List<User>> GetUsersAsync()
{
List<User> readUsers = new List<User>();
string connection = "server=myserverip;database=db;user=user;password=pwd";
using (MySqlConnection con = new MySqlConnection(connection))
{
MySqlCommand cmd = new MySqlCommand("SELECT * FROM admin", con);
cmd.CommandType = CommandType.Text;
con.Open();
MySqlDataReader rdr = cmd.ExecuteReader();
while(rdr.Read())
{
User user = new User();
user.ID = Convert.ToInt32(rdr["ID"]);
user.Username = rdr["Username"].ToString();
user.Password = rdr["Password"].ToString();
readUsers.Add(user);
}
}
return readUsers;
}
Of course the connection string has other values than displayed above (because of security reasons). I'm getting following errors and I just don't know how to solve them or what exactly the problem is:
I'm not sure how to continue or what to try now.