如何在没有SSL的情况下连接到MySQL数据库

问题描述:

我正在尝试连接到本地MySQL数据库.

I'm trying to connect to a local MySQL DB.

我有这个连接器:

using(MySqlConnection conn = new MySqlConnection("Database=Studentenverwaltung;Port=3306;Data Source=127.0.0.1;User Id=root;Password=abc123")) 
{
    try 
    {
        conn.Open();
        Console.WriteLine("Opened!");
        conn.Close();
    }
    catch(Exception e) 
    {
        Console.WriteLine("Cannot open Connection");
        Console.WriteLine(e.ToString());
    }
}

但是我得到了这个例外:

But I get this Exception:

MySql.Data.MySqlClient.MySqlException(0x80004005):主机127.0.0.1不支持SSL连接.

MySql.Data.MySqlClient.MySqlException (0x80004005): The host 127.0.0.1 does not support SSL connections.

似乎无法连接到数据库,因为该数据库不支持SSL.那么有没有办法在没有SSL的情况下连接到数据库?

It seems that it cannot connect to the DB because the DB doesn't support SSL. So is there a way how to connect to the DB whithout SSL?

您是否尝试在连接字符串中将 SslMode 属性设置为"none"?

Have you tried to set the SslMode property to 'none' in your connection string?

这应该有效:

new MySqlConnection("Database=Studentenverwaltung;Port=3306;Data Source=127.0.0.1;User Id=root;Password=abc123;SslMode=none;")