当前位置:网站首页>.NET(C#) MySQL conn.Open()报错:SSL Connection error的解决方法
.NET(C#) MySQL conn.Open()报错:SSL Connection error的解决方法
2022-04-23 01:17:00 【大数据苦行僧—yisurvey123】
简介:
本文主要介绍.NET(C#)中,使用MySQL数据库调用MySqlConnection对象的Open()方法时,报错:MySql.Data.MySqlClient.MySqlException (0x80004005): SSL Connection error.的解决方法。
使用示例代码:
public async void SQLInsert()
{
string connStr = "Server=echstreme.de;User=c1Look;Database=c1Look;Port=3306;Password=redacted;";
MySqlConnection conn = new MySqlConnection(connStr);
try
{
await SendEmbedMessage("MySQL", "Attempting to connect to database");
conn.Open();
await SendEmbedMessage("MySQL", "Connection to Database Successful");
MySqlCommand cmd = new MySqlCommand(sqlQuery, conn);
cmd.ExecuteNonQuery();
conn.Close();
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
报错信息:
MySql.Data.MySqlClient.MySqlException (0x80004005): SSL Connection error.
---> System.AggregateException: One or more errors occurred. (The handshake failed due to an unexpected packet format.)
---> System.IO.IOException: The handshake failed due to an unexpected packet format.
at System.Net.Security.SslStream.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslStream.PartialFrameCallback(AsyncProtocolRequest asyncRequest)
--- End of stack trace from previous location where exception was thrown ---
at System.Net.Security.SslStream.ThrowIfExceptional()
at System.Net.Security.SslStream.InternalEndProcessAuthentication(LazyAsyncResult lazyResult)
at System.Net.Security.SslStream.EndProcessAuthentication(IAsyncResult result)
at System.Net.Security.SslStream.EndAuthenticateAsClient(IAsyncResult asyncResult)
at System.Net.Security.SslStream.<>c.<AuthenticateAsClientAsync>b__64_2(IAsyncResult iar)
at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at MySql.Data.Common.Ssl.StartSSL(Stream& baseStream, Encoding encoding, String connectionString)
at MySql.Data.Common.Ssl.StartSSL(Stream& baseStream, Encoding encoding, String connectionString)
at MySql.Data.MySqlClient.NativeDriver.Open()
at MySql.Data.MySqlClient.Driver.Open()
at MySql.Data.MySqlClient.Driver.Create(MySqlConnectionStringBuilder settings)
at MySql.Data.MySqlClient.MySqlPool.CreateNewPooledConnection()
at MySql.Data.MySqlClient.MySqlPool.GetPooledConnection()
at MySql.Data.MySqlClient.MySqlPool.TryToGetDriver()
at MySql.Data.MySqlClient.MySqlPool.GetConnection()
at MySql.Data.MySqlClient.MySqlConnection.Open()
at Bot.Admins.AdminCommands.SQLInsert() in C:\Users\Owner\source\repos\Bot\Bot\Admins\AdminCommands.cs:line 71
解决方法:
如果服务器不支持SSL,可以使用SSL模式选项,None或Required。
连接字符串需要这样写:
"Server=echstreme.de;User=c1Look;Database=c1Look;Port=3306;Password=redacted;SSL Mode=None"
了解更多分析及数据抓取可查看:
http://cloud.yisurvey.com:9081/html/529942a8-212c-4c85-9c92-9c56beb4a299.html?ly=csdn
特别说明:本文旨在技术交流,请勿将涉及的技术用于非法用途,否则一切后果自负。如果您觉得我们侵犯了您的合法权益,请联系我们予以处理。
版权声明
本文为[大数据苦行僧—yisurvey123]所创,转载请带上原文链接,感谢
https://blog.csdn.net/weixin_52026996/article/details/124325972
边栏推荐
- After ten years of testing experience, I have sorted out the most suitable software testing learning guide for you
- Three technical solutions of ant group were selected as "typical solutions for information technology application and innovation in 2021"
- Here's the point. Have you mastered the most complete Web3 jargon guide?
- Enterprises choose to privatize the deployment of IM instant messaging software to fully protect information security!
- gin--hello
- Why should I object to DBA's participation in business (issuing reports / changing data)
- 光猫超级帐号密码,重置光猫获取超级帐号密码
- Live broadcast software | IPTV live broadcast software | TV live broadcast | tvplayer IPTV easyplayer | youwo live broadcast | customized development of super live broadcast software
- Elk setup (IV): monitor MySQL slow query and error log
- Error: permissionerror: [winerror 32] this file is in use by another program and cannot be accessed by the process. Solution of "+ file path"
猜你喜欢

"Open source summer" activity is hot. In the registration, rich bonuses are waiting for you to get!

Acrel-5000型建筑能耗监测系统在西咸空港花园项目的研究与应用

Common problems and solutions of crashsight access reporting

What happens when you run the NPM install command?

engine.POST()处理POST请求

Research and application of Acrel-5000 building energy consumption monitoring system in Xixian Airport Garden Project

Chapter 9 of C language programming (fifth edition of Tan Haoqiang) analysis and answer of exercises for users to establish their own data types

体育训练中心项目电力监控系统的研究与应用
Elk setup (IV): monitor MySQL slow query and error log

Huawei CDN is fast everywhere
随机推荐
Detailed explanation of Milvus 2.0 quality assurance system
Research and application of Acrel-5000 building energy consumption monitoring system in Xixian Airport Garden Project
Open WebRTC Toolkit(OWT) Server User Guide
Cloud native Virtualization: building edge computing instances based on kubevirt
曦智科技沈亦晨入选2022达沃斯世界经济论坛“全球青年领袖”
Let's talk about ruby
[interview skills] how to face an interview without a leading group
Smart business card applet business card details page function implementation key code
VS+C# 实现窗体输入框默认显示灰色文字
Optical cat super account password, reset optical cat to obtain super account password
Cross domain problem and solving cross domain problem by UMI proxy proxy
How to become a real digital enterprise? Ruijie network releases the digital force awakening plan
How to introduce SPI into a project
Processus d'analyse et de configuration du matériel IIC pour le développement de la machine nue imx6ull
Pilotage growth · ingenuity empowerment -- yonmaster developer training and pilotage plan is fully launched
Flash project cross domain interception and DBM database learning [Baotou cultural and creative website development]
200. Number of islands
Three technical solutions of ant group were selected as "typical solutions for information technology application and innovation in 2021"
IMX6ULL裸机开发之硬件SPI分析及配置过程
Hardware SPI analysis and configuration process of imx6ull bare metal development