简体   繁体   English

使用方法 mysql_native_password 验证失败

[英]Authentication failed using method mysql_native_password

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:尝试使用 Visual Studio 2012 Update 3 中的 Connector/Net C#/WinForms 连接到我的 Web 主机上的 MySQL,但收到以下错误消息:

Authentication to host '1.1.1.1' for user 'username@mydomain.com' using method 'mysql_native_password' failed with message: Access denied for user 'username@mydomain.com'@'2.2.2.2' (using password: YES)使用方法“mysql_native_password”对用户“username@mydomain.com”的主机“1.1.1.1”进行身份验证失败,并显示消息:用户“username@mydomain.com”@“2.2.2.2”的访问被拒绝(使用密码:是)

string connectionString = "SERVER=1.1.1.1;PORT=3306;DATABASE=databaseName;UID=username@mydomain.com;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 username@mydomain.com) but it gave me the below error:我最初尝试了没有域的用户名(用户名而不是 username@mydomain.com),但它给了我以下错误:

Authentication with old password no longer supported, use 4.1 style passwords.不再支持使用旧密码进行身份验证,请使用 4.1 样式的密码。

Any assistance would be much appreciated, thanks!任何帮助将不胜感激,谢谢!

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 服务器的域名添加到能够访问您网站上的数据库的主机列表中来允许外部 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 地址。

Two possible things:两种可能的情况:

  1. MySQL is case sensitive make sure that the case of Database= in your connection string matches with the actual database name MySQL区分大小写确保连接字符串中Database=的大小写与实际数据库名称匹配
  2. You may have to grant privileges to the user.您可能必须向用户授予权限。

I hope this help you.我希望这对你有帮助。

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!但事实并非如此!

After creating a new user in MySQL, in MySQL Workbench "Test Connection" will succeed but the C# MySqlConnection.Open() will throw the same exception and message as the question (tested with localhost and 127.0.0.1 and the local ip address).在 MySQL 中创建新用户后,在 MySQL Workbench 中“测试连接”将成功,但 C# MySqlConnection.Open()将抛出与问题相同的异常和消息(使用 localhost 和127.0.0.1以及本地 IP 地址进行测试)。

The reason is that MySqlConnection.Open() will somehow use SELECT privilege, and you need to at least enable the SELECT privilege for the new user.原因是MySqlConnection.Open()会以某种方式使用 SELECT 权限,您至少需要为新用户启用 SELECT 权限。 The error message is misleading.错误消息具有误导性。

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 上基于特定 Membership SQL Server 指令的情况有关,解决方法是在 web.config 中创建新成员,删除 mvc 4 AccountControler 并在此处或 Internet 中使用 MVC3 中的旧成员:

http://www.nsilverbullet.net/2012/11/06/using-mysql5-as-membership-backend-for-aspnet45-mvc4-application/ http://www.nsilverbullet.net/2012/11/06/using-mysql5-as-membership-backend-for-aspnet45-mvc4-application/

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.还要检查用户是否已添加到数据库并具有权限。

对我来说,使用实际 IP 地址而不是域名解决了问题

在cpanel上将我的IP列入白名单时,我不小心在我的IP地址后面放了一个空格。[应该由他们处理]我再次添加了IP并且它起作用了。

In my case, the problem was misleading as well.就我而言,这个问题也具有误导性。 Had quite a few windows terminals running "the same" .net app all connecting to a remote MySQL server (installed in a windows server machine).有不少运行“相同”.net 应用程序的 Windows 终端都连接到远程 MySQL 服务器(安装在 Windows 服务器机器中)。 However, only one always popping the specific error when anyone clicked to run the .net application.但是,当任何人单击运行 .net 应用程序时,只有一个总是弹出特定错误。 ODBC test connection passed successfully, and no matter if the error popped, when presing OK the application continued loading successfully finally and then worked fine.But again afterwards , when anyone tried to run in for the first time the message appeared. ODBC测试连接成功通过,无论是否弹出错误,当按下OK时,应用程序最终成功加载,然后工作正常。但之后再次,当有人第一次尝试运行时出现消息。 and I repeat only in this specific terminal!我只在这个特定的终端重复! The fix finally came when I noticed, that it was only in this specific terminal with the problem that we had forgotten DHCP enabled!当我注意到时,修复终于来了,只有在这个特定的终端中,我们忘记了启用 DHCP 的问题! and "although it was given always the same IP" from our IT policies, however it only worked when we disabled DHCP and set this IP, SUBNET and GW, as fixed !以及我们的 IT 策略中的“虽然它总是被赋予相同的 IP”,但是它仅在我们禁用 DHCP 并将此 IP、SUBNET 和 GW 设置为固定时才有效!

Commenting here in case anyone is as absolutely dimwitted as me: Somehow the semicolon after the password had gotten deleted, so it was running together with the next item in the connection string.在这里评论以防万一有人像我一样绝对愚蠢:不知何故,密码后的分号被删除了,所以它与连接字符串中的下一项一起运行。 Easy to overlook if your password has a bunch of symbols in it.如果您的密码中有一堆符号,则很容易被忽视。

Check with a program like Navicat that the mysql server user has a native password.使用 Navicat 之类的程序检查 mysql 服务器用户是否有本机密码。 Everything is correct but if you are getting this error check the version of the link DLL一切都正确,但如果您收到此错误,请检查链接 DLL 的版本

This error;这个错误; Mysql.Data.dll and Mysql Server version mismatch error. Mysql.Data.dll 和 Mysql Server 版本不匹配错误。 Download and install an older version下载并安装旧版本

https://downloads.mysql.com/archives/c-net/ https://downloads.mysql.com/archives/c-net/

Mysql Version < 4.5 mysql 版本 < 4.5

Mysql.Data.Dll version= 6.0.3 Mysql.Data.Dll 版本= 6.0.3

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用方法“ mysql_native_password”对主机或用户进行身份验证失败 - authentication to host or user using method 'mysql_native_password' failed 使用方法“ mysql_native_password”失败 - using method 'mysql_native_password' failed 使用方法 &#39;mysql_native_password&#39; 对用户 &#39;root&#39; 的主机 &#39;localhost&#39; 进行身份验证失败并显示消息(使用密码:否) - Authentication to host 'localhost' for user 'root' using method 'mysql_native_password' failed with message (using password: NO) 使用方法“mysql_native_password”对用户“root”的主机“127.0.0.1”进行身份验证失败,并显示消息:未知数据库“xxx” - Authentication to host '127.0.0.1' for user 'root' using method 'mysql_native_password' failed with message: Unknown database 'xxx' 使用方法“mysql_native_password”对用户“用户名”的主机“192.168.0.31”进行身份验证失败,并显示消息:未知数据库“mysql57” - Authentication to host '192.168.0.31' for user 'username' using method 'mysql_native_password' failed with message: Unknown database 'mysql57' 如何修复“使用方法 &#39;mysql_native_password&#39; 为用户进行身份验证失败并显示消息:从流中读取失败。” 在.NET中 - How to fix 'Authentication to host for user using method 'mysql_native_password' failed with message: Reading from the stream has failed.' in .NET C# - 意外的身份验证方法 mysql_native_password 异常 - C# - Unexpected authentication method mysql_native_password exception 方法&#39;mysql_native_password&#39;失败并显示消息:用户&#39;&#39;@&#39;RAHUL-PC&#39;的访问被拒绝(使用密码:是) - method 'mysql_native_password' failed with message: Access denied for user ''@'RAHUL-PC' (using password: YES) 从流读取失败 - mysql_native_password错误 - Reading from stream failed - mysql_native_password error Firebase Unity密码身份验证失败 - Firebase Unity password authentication failed
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM