unity 与数据库mysql连接的注意事项
(1)unity 中mysql 8.0 与mysql connector net 6.10.7较为适配;且,mysql 8.0与mysql connector net 7.0.2及以上。随着MySQL 8.0的发布,MySQL引入了新的默认身份验证插件。然而,这可能导致与旧版客户端或某些编程语言库的不兼容性。考虑更新你的mysql connector net。与mysql connector ne
·
(1)unity 中mysql 8.0 与mysql connector net 6.10.7较为适配;
随着MySQL 8.0的发布,MySQL引入了新的默认身份验证插件caching_sha2_password,以提高安全性。然而,这可能导致与旧版客户端或某些编程语言库的不兼容性问题。如果你遇到连接错误,提示与caching_sha2_password有关。考虑更新你的mysql connector net。
经过测试,mysql 8.0 与mysql connector net 6.10.7不存在这个问题;且,mysql 8.0与mysql connector net 7.0.2及以上均不适配;
(2)unity连接MySQL数据库时,提示SSL Authentication Error连接失败。
SSL Authentication Error解决方法,在连接字符串中添加SslMode=none;AllowPublicKeyRetrieval=True;即可。
(3)示例 连接语句
private MySqlConnection connection;
public void Init()
{
string sqlString = "server=localhost;user=root;password=123456;database=yuan;SslMode=none;AllowPublicKeyRetrieval=True;";
connection = new MySqlConnection(sqlString);
try
{
connection.Open();
}
catch (System.Exception e)
{
Debug.Log("数据库连接失败" + e.Message);
}
}
public void Close()
{//关闭与服务器数据库的连接;
connection.Close();
}
(4)mysql connector 下载相关链接:MySQL :: Download MySQL Connector/NET (Archived Versions)
更多推荐




所有评论(0)