当前位置:网站首页>.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
边栏推荐
- 智能手表的下半场,机遇与挑战并存
- Introduction to Alibaba's super large-scale Flink cluster operation and maintenance system
- Terminal mobile JD Mall
- Cai Guoqiang's fireworks NFT debut is as wonderful as fireworks during the day
- 员工公寓楼建设项目电力监控系统的研究与应用
- Is it difficult for girls to learn software testing?
- [actf2020 freshman competition]
- Workplace PUA, five sins of managers
- Scope of define
- Branch and loop statements
猜你喜欢

Fault analysis | federated storage engine table causes the monitoring thread to be in the opening table state

智能照明控制系统在医院的设计与应用

How to become a real digital enterprise? Ruijie network releases the digital force awakening plan
![[HCTF 2018]admin](/img/08/8111f2f87796dda8dd6b0dcf72c42b.png)
[HCTF 2018]admin

Acrel-5000型建筑能耗监测系统在西咸空港花园项目的研究与应用
![Error: permissionerror: [winerror 32] this file is in use by another program and cannot be accessed by the process. Solution of](/img/eb/9031f00e41666941219974ea2e2274.png)
Error: permissionerror: [winerror 32] this file is in use by another program and cannot be accessed by the process. Solution of "+ file path"

Is it difficult for girls to learn software testing?

【Android工程师与智能家居产品的第一次接触③】SmartConfig一键配网在硬件端的具体实现|ESP8266一键配网在Arduino的具体实现|玉念聿辉

Pilotage growth · ingenuity empowerment -- yonmaster developer training and pilotage plan is fully launched

你真的会用K折交叉吗? 对于K折交叉的思考
随机推荐
Basic operation of Android local database | multi thread operation database | addition, deletion, modification and query of database | batch insertion into database | basic use of thread pool | Yu nia
From construction to governance, the industry's first white paper on microservice governance technology was officially released (including a free download link)
Frequently asked questions about recent BSN development
Enterprises choose to privatize the deployment of IM instant messaging software to fully protect information security!
The code bought from the salted fish | SSM hotel room management system | whether the purchased source code can really be used | confusion from the programmer | Yu Nianyu Hui | Wu Minghui, dachou Vill
【以太网交换安全】--- 交换机流量控制/DHCP Snooping/IP Source Guard
Basic knowledge of software testing (detailed version) collection of this article is enough
Alibaba cloud container & Service Grid product technology trends (202203)
Im instant messaging development how to design a database that can support millions of concurrent users
Source code analysis of synchronousqueue
Jijian cloud x servicego: help hardware manufacturers realize intelligent management of equipment repair and maintenance
Chapter 9 of C language programming (fifth edition of Tan Haoqiang) analysis and answer of exercises for users to establish their own data types
What is tooljet and how about it—— Evaluation of low code development platform
What is October 24th? Why are there no senior programmers in China in their fifties and sixties, while foreigners,,, Yu Nianyu Hui take you to celebrate the 1024 programmer Festival
DCB "first brother" xianruida, what does it rely on to raise the value curve?
Good test data management, in the end how to do?
What happens when you run the NPM install command?
Thingskit Internet of things platform
Get rid of the "small workshop" of AI production: how to build a cloud native AI platform based on kubernetes
Free trial for the first three months! Borui data alarm platform onealert is in progress