jeudi 30 juin 2016

I'm unable to connect to MySql DB remotely from my C# application

How can I connect to my MySql DB on godadday from my C# application? I tried looking for settings to enable this and cannot find it. Also what IP address should I be using? I'm connecting to my site using the IP address given to me with and without port 3306 to no success.

ERROR: I x'ed out the server ip and user

An unhandled exception of type 'MySql.Data.MySqlClient.MySqlException' occurred in MySql.Data.dll

Additional information: Authentication to host 'xxx.xx.xxx.xxx' for user 'xxxxx' using method 'mysql_native_password' failed with message: Access denied for user 'xxxxx'@'c-73-12-216-99.hsd1.ca.comcast.net' (using password: YES)

CODE:

public static bool Connect(string userName, string password, string server, string database)
    {
        MySqlConnectionStringBuilder conn_string = new MySqlConnectionStringBuilder();
        conn_string.Server = server;
        conn_string.UserID = userName;
        conn_string.Password = password;
        conn_string.Database = database;
        conn_string.Port = 3306;

        string con = conn_string.ToString();
        using (MySqlConnection conn = new MySqlConnection(con))
        using (MySqlCommand cmd = conn.CreateCommand())
        {                    
            conn.Open();                
            cmd.ExecuteNonQuery();
        }

        return true;
    }

Aucun commentaire:

Enregistrer un commentaire