Access denied error with MySQL Connector/NET 6.9.9
Posted by: Dan Hermann
Date: December 20, 2016 09:07AM

I'm trying to port a Golang/MySQL app to C#/MySQL app using MySQL Connector/NET 6.9.9 that I installed via NuGet. My test app for verifying MySQL connectivity is very simple:

string connStr = "server=192.168.5.3; protocol=tcp; pooling=false; uid=pdanuser; database=pdan; port=3306; pwd=<redacted>;";
MySqlConnection conn = new MySqlConnection(connStr);
try
{
Console.WriteLine("Connecting to MySQL...");
conn.Open();

string sql = "SELECT <redacted> FROM <redacted> limit 100";
MySqlCommand cmd = new MySqlCommand(sql, conn);
MySqlDataReader rdr = cmd.ExecuteReader();

while (rdr.Read())
{
Console.WriteLine(rdr[0] + " -- " + rdr[1]);
}
rdr.Close();
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
conn.Close();
Console.WriteLine("Done.");


I get the following error:

Connecting to MySQL...
MySql.Data.MySqlClient.MySqlException (0x80004005): Authentication to host '192.168.5.3' for user 'pdanuser' using method 'mysql_native_password' failed with message: Access denied for user 'pdanuser'@'ip-192-168-5-35.ec2.internal' (using password: YES) ---> MySql.Data.MySqlClient.MySqlException (0x80004005): Access denied for user 'pdanuser'@'ip-192-168-5-35.ec2.internal' (using password: YES)
at MySql.Data.MySqlClient.MySqlStream.ReadPacket()
at MySql.Data.MySqlClient.Authentication.MySqlAuthenticationPlugin.ReadPacket()
at MySql.Data.MySqlClient.Authentication.MySqlAuthenticationPlugin.AuthenticationFailed(Exception ex)
at MySql.Data.MySqlClient.Authentication.MySqlAuthenticationPlugin.ReadPacket()
at MySql.Data.MySqlClient.Authentication.MySqlAuthenticationPlugin.Authenticate(Boolean reset)
at MySql.Data.MySqlClient.NativeDriver.Authenticate(String authMethod, Boolean reset)
at MySql.Data.MySqlClient.NativeDriver.Open()
at MySql.Data.MySqlClient.Driver.Open()
at MySql.Data.MySqlClient.Driver.Create(MySqlConnectionStringBuilder settings)
at MySql.Data.MySqlClient.MySqlConnection.Open()
at MySqlTester1.Program.Main(String[] args) in C:\Dev\DotNet\MySqlTester1\MySqlTester1\Program.cs:line 15
Done.

I know that I have no network or authentication problems because the Golang app successfully runs on this machine against the same MySQL database using the same username and password. I've googled for this error and seen some suggestions about uninstalling and reinstalling MySQL Connnector, but none of those have worked for me. Any suggestions would be very welcome.

Dan

Options: ReplyQuote


Subject
Written By
Posted
Access denied error with MySQL Connector/NET 6.9.9
December 20, 2016 09:07AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.