使用 raspbian 在 C# 应用程序中连接到 MariaDB

Connecting to MariaDB in C# Application using raspbian

我一直在尝试 运行 我的 pi3 上的服务器使用 mysql (mariadb) 并像这样连接:

mySQLSettings.connection = new MySqlConnection("SERVER=localhost;DATABASE=servertest;UID=root;PASSWORD=;");
mySQLSettings.connection.Open();

当我使用 XAMPP 时,它在 Windows 上工作得很好。然而,当我 运行 我的 pi 上的应用程序时,它会抛出这个:

Could not connect to MySQL: MySql.Data.MySqlClient.MySqlException (0x80004005): Client does not support authentication protocol requested by server; consider upgrading MariaDB client
  at MySql.Data.MySqlClient.MySqlStream.ReadPacket () [0x0006e] in <61bbf0b98df94765b3636dc3aa92c9d7>:0
  at MySql.Data.MySqlClient.NativeDriver.AuthenticateNew (System.Boolean reset) [0x000ed] in <61bbf0b98df94765b3636dc3aa92c9d7>:0
  at MySql.Data.MySqlClient.NativeDriver.Authenticate (System.Boolean reset) [0x00040] in <61bbf0b98df94765b3636dc3aa92c9d7>:0
  at MySql.Data.MySqlClient.NativeDriver.Open () [0x00344] in <61bbf0b98df94765b3636dc3aa92c9d7>:0
  at MySql.Data.MySqlClient.Driver.Open () [0x0000c] in <61bbf0b98df94765b3636dc3aa92c9d7>:0
  at MySql.Data.MySqlClient.Driver.Create (MySql.Data.MySqlClient.MySqlConnectionStringBuilder settings) [0x00058] in <61bbf0b98df94765b3636dc3aa92c9d7>:0
  at MySql.Data.MySqlClient.MySqlPool.CreateNewPooledConnection () [0x0001e] in <61bbf0b98df94765b3636dc3aa92c9d7>:0
  at MySql.Data.MySqlClient.MySqlPool.GetPooledConnection () [0x000b5] in <61bbf0b98df94765b3636dc3aa92c9d7>:0
  at MySql.Data.MySqlClient.MySqlPool.TryToGetDriver () [0x00051] in <61bbf0b98df94765b3636dc3aa92c9d7>:0
  at MySql.Data.MySqlClient.MySqlPool.GetConnection () [0x00021] in <61bbf0b98df94765b3636dc3aa92c9d7>:0
  at MySql.Data.MySqlClient.MySqlConnection.Open () [0x0013e] in <61bbf0b98df94765b3636dc3aa92c9d7>:0
  at GameServer.MySQL.ConnectToMySQLServer () [0x00000] in <16fb46a8a2244c9e90373e583102cae7>:0

MariaDB 的版本是 10.3.22,我使用的是 MySql.Data-6.4 dll

我是不是漏掉了一些简单的东西?

提前致谢!

您使用的 MySql.Data.dll 版本很旧,它可能不支持您的服务器正在使用的身份验证方案。

在这种情况下,我建议切换到 MySqlConnector, which has better client support for MariaDB, including its auth_gss_client and auth_ed25519 authentication schemes (the latter in a separate package)。