gpt4 book ai didi

c# - MySQL 连接错误 : Value Preferred is not of the correct type mysql

转载 作者:行者123 更新时间:2023-11-30 21:56:11 25 4
gpt4 key购买 nike

我正在 Ubuntu 服务器上使用 MySQL 开发 .NET Core 项目。我在 Mac 上使用 Visual Studio。我安装的 NuGet 包是 MySql.Data 8.0.8-dmr,它不是一个稳定版本(也许这就是重点,但让我继续)。

我在那台机器上没有 SSL 证书,它只是在本地网络中用于开发目的。

我正在使用如下所示的连接字符串:服务器 = [该服务器的 IP 地址];端口=3306;数据库=我的数据库; Uid=我的用户;密码=我的密码; SslMode=首选;

当我使用配置为“如果可用”的 SSL 模式连接 MySQL Workbench 时,连接工作正常。当我尝试用我的代码进行此连接时,抛出了 System.ArgumentException 类型的异常:

Value 'Preferred' is not of the correct type.

如果我在连接字符串中将 SslMode 更改为“None”,我的代码就可以连接到 MySQL 服务器。

我不明白,为什么它不适用于“首选”值。无论如何,当我说“首选”时,它不应该是后备选项吗?

MySQL 服务器有这个版本:5.7.18-0ubuntu0.16.04.1。

最佳答案

检查此链接 MySQL connection strings .您需要有 Connector/.Net 包,我认为您没有。此外,您至少需要 6.2.1 版。

此外,这里是 Deployment guide关于如何在 Ubuntu 服务器上部署它。!

enter image description here

关于 this link 的另一条注释,SslMode 的默认值是“Preferred”,所以我认为那里没有问题。

关于c# - MySQL 连接错误 : Value Preferred is not of the correct type mysql,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45118773/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com