方法“ mysql_native_password”失败,并显示以下消息:对用户“ @'RAHUL-PC”的访问被拒绝(使用密码:是)

时间:2019-06-29 15:11:37

标签: c# asp.net

我又要问一部分问题。我正在使用Windows 7作为客户端和Windows 2012作为服务器。使用以下代码:-

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MySql.Data.Common;
using MySql.Data.MySqlClient;

public partial class college_data : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

protected void ButtonSave_Click(object sender, EventArgs e)
{

        //String DSN = "Data Source = win2012server.db.net; port = 3306; Initial Catalog = collegedata, UserId = rahul; password = rahul; sslmode = none";
        String DSN = "Data Source = win2012server.db.net; port = 3306; Database = collegedata, Uid = rahul; Pwd = rahul;";
        MySqlConnection conn = new MySqlConnection(DSN);

        conn.Open();
        if (conn != null)
        {
            String sql = "insert into studentdata values('" + TextBoxRollNo.Text.Trim() + "', '" + TextBoxStudentName.Text.Trim() + "' , '" + TextBoxFatherName.Text.Trim() + "'" +
                          "'" + TextBoxMotherName.Text.Trim() + "'";
                MySqlCommand cmd = new MySqlCommand();
            cmd.CommandText = sql;

            cmd.Connection = conn;
            cmd.ExecuteNonQuery();
            LabelDisplay.Text = "data saved";
        }
        else
        {
            LabelDisplay.Text = "connection not opened";
        }
    }
}

错误:-

 Authentication to host 'win2012server.db.net' for user '' using method 'mysql_native_password' failed with message: Access denied for user''@'RAHUL-PC' (using password: YES)

点conn.open()。 如何解决此错误。

0 个答案:

没有答案