Code: Select all
Devart.Data.MySql.MySqlException
Message = Access denied for user [...] to database [...]
SqlState = 42000
Code = 1044
InnerException = null
Code: Select all
Devart.Data.MySql.MySqlException
Message = Can't connect to MySQL server on [...] (10061): Authentication failed
SqlState = 00000
Code = 2003
InnerException: Devart.Common.aj
Message = Transport channel is closed
From http://dev.mysql.com/doc/refman/5.1/en/ ... erver.html:The error (2003) Can't connect to MySQL server on 'server' (10061) indicates that the network connection has been refused. You should check that there is a MySQL server running, that it has network connections enabled, and that the network port you specified is the one configured on the server.
Here is a C# SSCE to demonstrate. Note that the MySQL user must have no privileges to open a connection to the given database. For ease of use, the database credentials are parameters.Error: 1044 SQLSTATE: 42000 (ER_DBACCESS_DENIED_ERROR)
Message: Access denied for user '%s'@'%s' to database '%s'
Code: Select all
using System;
namespace DevartSSCE
{
class Program
{
static void Main(string[] args)
{
int test = 0;
for (int i = 0; i < 100; i++)
{
if (go(args))
{
test++;
}
}
Console.WriteLine("Incorrect: " + test);
Console.WriteLine();
Console.WriteLine("\nPress enter to exit");
Console.Read();
}
static bool go(string[] args)
{
string user = args[0];
string pass = args[1];
string host = args[2];
string schema = args[3];
string ssl_ca = args[4];
string ssl_cert = args[5];
string ssl_key = args[6];
bool otherExceptionCaught = false;
string connStr = "User Id=" + user + ";" +
"Password=" + pass + ";" +
"Host=" + host + ";" +
"Database=" + schema + ";" +
"Protocol=Ssl;" +
"Pooling=False;" +
"SSL CA Cert=file://" + ssl_ca + ";" +
"SSL Cert=file://" + ssl_cert + ";" +
"SSL Key=file://" + ssl_key + ";" +
"Validate Connection=True;";
Devart.Data.MySql.MySqlConnection conn = new Devart.Data.MySql.MySqlConnection(connStr);
try
{
conn.Open();
}
catch (Devart.Data.MySql.MySqlException ex)
{
if (ex.Message == "Access denied for user '" + user + "'@'" + host + "' to database '" + schema + "'")
{
Console.WriteLine("Correct exception caught");
}
else if (ex.Message == "Can't connect to MySQL server on '" + host + "' (10061): Authentication failed.")
{
otherExceptionCaught = true;
Console.WriteLine("Incorrect exception caught");
}
else
{
throw;
}
}
finally
{
conn.Close();
}
return otherExceptionCaught;
}
}
}