public static void Main()
{
MySqlConnection conn = new MySqlConnection("Database=yourDataBase;Data Source=localhost;User Id=yourmysqlaccount;Password=yourpassword");
try
{
conn.Open();
}
catch(Exception ex)
{
Console.WriteLine(ex.ToString());
throw ex;
}
Console.WriteLine($"ConnectionState:{conn.State}");
MySqlCommand cmd = conn.CreateCommand();
cmd.CommandText = "show tables;";
MySqlDataReader rdr = cmd.ExecuteReader();
while (rdr.Read())
{
Console.WriteLine(rdr[0].ToString()); ;
}
rdr.Close();
conn.Close();
Console.WriteLine($"ConnectionState:{conn.State}");
}