我正在尝试使用 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 IP
是azure
。即 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/