配置文件中定义连接字符串:
"db": "server=10.0.0.0;database=Test;uid=sa;pwd=123456;Allow User Variables=true;default command timeout=120;Pooling=true;Max Pool Size=1000;"
建立数据库连接:
public override IDbConnection GetConnection()
IDbConnection conn = new MySqlConnection(_config["db"]);
if (conn.State != ConnectionState.Open)
conn.Open();
return conn;
Message: \"SSL Authentication Error\", InnerException: AuthenticationException { TargetSite: Void Throw(), StackTrace: \" at System.Net.Security.SslStream.StartSendAuthResetSignal(ProtocolToken message, AsyncProtocolRequest asyncRequest, ExceptionDispatchInfo exception
问题原因:如果MySQL.Data.dll是高版本(8.0.8或者以上),并且MySQL也是5.7.78或者以上的版本,MySQL.Data.dll数据库驱动程序中新增了SSL安全模式,默认情况下是开启的。所以,我们需要在.NET的数据库连接字符串中显式关闭SSL模式
解决方案:
"db": "server=10.0.0.0;database=Test;uid=sa;pwd=123456;Allow User Variables=true;default command timeout=120;Pooling=true;Max Pool Size=1000;SslMode=none;"