c# - 如何正确连接MySQL数据库与C#应用程序?

标签 c# mysql azure ado.net

我正在尝试使用 C# 连接我的 MySQL 数据库,但无法连接。

我正在使用

static string connstring = @"server=my.live.ip;userid=user;password=123;database=db_name;port=3306";

但我仍然得到

Authentication to host 'my.live.ip' for user 'user' using method 'mysql_native_password' failed with message: Access denied for user 'user'@'202.xxx.xxx.xxx' (using password: NO)`

我已经搜索过但没有找到任何合适的解决方案。

P.S:我使用的live IPazure。即 MySQL 数据库通过 xampp 托管在 azure 服务器上

任何帮助将不胜感激

最佳答案

(使用密码:NO)表示未提供密码。我不熟悉 C# 的连接语法,但我怀疑

static string connstring =
     @"server=my.live.ip;userid=user;password=123;database=db_name;port=3306";

或者也许没有使用connstring

还要检查 MySQL 方面。执行 SHOW GRANTS FOR 'user'@'202%'SHOW GRANTS FOR 'user'@'202.xxx.xxx.xxx',具体取决于您是否使用'202%''202.xxx.xxx.xxx' 作为“主机”。

你应该返回类似的东西

GRANT ... ON dbname.* TO 'user'@'202%' WITH AUTHENTICATION 'mysql_native_password';

注意:主机名与 IP 地址可能是一个问题。

关于c# - 如何正确连接MySQL数据库与C#应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62097919/

相关文章:

c# - C# 中的双泛型类型

MySQL:为什么我的 INSERT 语句在自动增加 id 时会跳过 56 个数字?

Azure 存储 Blob : set CORS on the blobs level?

azure - 通知中心未授权异常 : Unauthorized on Azure Notification Hub registration

c# - 如何将 C# 控制台应用程序部署为单个 exe?

c# - 从 c# 读取 excel,有什么新的吗?

c# - WPF 数据网格行上下文菜单 - 禁用菜单项

php - 如何使用 php 获取 mysql 数据库中的表和行的列表? (这里是菜鸟)

php - MySql,循环(while foreach)

c# - 辅助角色 localstorage 的目录未找到异常