C# 使用方法 mysql_native_password 进行身份验证失败
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17647816/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Authentication failed using method mysql_native_password
提问by Badger Sharescott
Trying to connect to MySQL on my web host, using Connector/Net C#/WinForms in Visual Studio 2012 Update 3, but getting the below error message:
尝试在我的 Web 主机上连接到 MySQL,在 Visual Studio 2012 Update 3 中使用 Connector/Net C#/WinForms,但收到以下错误消息:
Authentication to host '1.1.1.1' for user '[email protected]' using method 'mysql_native_password' failed with message: Access denied for user '[email protected]'@'2.2.2.2' (using password: YES)
使用方法“mysql_native_password”对用户“[email protected]”的主机“1.1.1.1”进行身份验证失败并显示消息:用户“[email protected]”@“2.2.2.2”的访问被拒绝(使用密码:是)
string connectionString = "SERVER=1.1.1.1;PORT=3306;DATABASE=databaseName;[email protected];PASSWORD=mypassword;";
MySqlConnection connection = new MySqlConnection(connectionString);
connection.Open();
I am connecting remotely, have whitelisted my IP (and even temporary whitelisted all (%) to test), triple checked the username and password and IP.
我正在远程连接,已将我的 IP 列入白名单(甚至将所有 (%) 临时列入白名单以进行测试),对用户名和密码以及 IP 进行了三次检查。
I originally tried the username without the domain ( username rather than [email protected]) but it gave me the below error:
我最初尝试使用没有域的用户名(用户名而不是 [email protected]),但它给了我以下错误:
Authentication with old password no longer supported, use 4.1 style passwords.
不再支持使用旧密码进行身份验证,请使用 4.1 样式密码。
Any assistance would be much appreciated, thanks!
任何帮助将不胜感激,谢谢!
回答by yadavr
Its problem of 'Remote Database Access Hosts'. "You can allow external web servers to access your MySQL databases by adding their domain name to the list of hosts that are able to access databases on your web site."
它的“远程数据库访问主机”问题。“您可以通过将其域名添加到能够访问您网站上的数据库的主机列表中来允许外部 Web 服务器访问您的 MySQL 数据库。”
MySql access is not granted to IP address of the system at which application is running.(in your case its '2.2.2.2' ).
MySql 访问权限未授予运行应用程序的系统的 IP 地址。(在您的情况下为 '2.2.2.2' )。
Note:- '2.2.2.2' is your public IP address.
注意:-“2.2.2.2”是您的公共 IP 地址。
回答by Leonel Maye
Two possible things:
两种可能的情况:
- MySQL is case sensitivemake sure that the case of
Database=in your connection string matches with the actual database name - You may have to grant privileges to the user.
- MySQL区分大小写,请确保
Database=连接字符串中的大小写与实际数据库名称匹配 - 您可能必须向用户授予权限。
I hope this help you.
我希望这对你有帮助。
回答by theshinylight
Check your application settings file (or wherever you have stored the connection string).
检查您的应用程序设置文件(或您存储连接字符串的任何位置)。
In my case the application was using the old connection string (which was not valid). I was assuming that the change I made in the code of the settings file is reflected to the designer (of the settings file). But it was not!
在我的情况下,应用程序使用的是旧的连接字符串(这是无效的)。我假设我在设置文件的代码中所做的更改会反映给(设置文件的)设计者。但事实并非如此!
回答by Robert Juz
This might be related to the case of specific Membership SQL Server based instructions on ASP.NET 4.5, workaround is to create new membership in web.config, drop mvc 4 AccountControler and use old from MVC3 more here or in the internet:
这可能与基于 ASP.NET 4.5 的特定成员资格 SQL Server 指令的情况有关,解决方法是在 web.config 中创建新成员资格,删除 mvc 4 AccountControler 并在此处或互联网上更多地使用 MVC3 中的旧版本:
回答by Syed Nasir Abbas
In my case updated password was not used. I just generated the password using Password Generator and copy it but forgot to click Change Password.
在我的情况下,未使用更新的密码。我刚刚使用密码生成器生成密码并复制它,但忘记单击更改密码。
Also check the user is added to the database and has Privileges.
还要检查用户是否已添加到数据库并具有权限。

