如何在没有SSL的情况下连接到MySQL数据库 [英] How to connect to a MySQL Database without SSL
本文介绍了如何在没有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;")
这篇关于如何在没有SSL的情况下连接到MySQL数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文