mysql 不通过ssl连接,有没有方法可以在没有SSL的情况下连接到MySQL数据库?

本文介绍了一种在尝试连接本地MySQL数据库时遇到的SSL连接问题及其解决方案。通过修改连接字符串中的SslMode属性为none,可以成功绕过SSL验证,实现数据库的正常连接。

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

I have this connector:

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): The host 127.0.0.1 does not support SSL connections.

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?

解决方案

Have you tried to add the SslMode property to your connection string?

This should work:

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值