简体   繁体   English

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

[英]method 'mysql_native_password' failed with message: Access denied for user ''@'RAHUL-PC' (using password: YES)

I'm asking again a part of question.我又问了一部分问题。 ASP.NET connection with MySQL remote serve.与 MySQL 远程服务的 ASP.NET 连接。 I'm using Windows 7 as client and Windows 2012 as server.我使用 Windows 7 作为客户端,使用 Windows 2012 作为服务器。 using following code :-使用以下代码:-

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";
        }
    }
}

Error:错误:

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)使用方法 'mysql_native_password' 对用户 '' 的主机 'win2012server.db.net' 进行身份验证失败,并显示消息:用户''@'RAHUL-PC' 的访问被拒绝(使用密码:是)

in point conn.open() .在点conn.open() How to solve this error?如何解决这个错误?

将此代码添加到 web.config 文件:

<siteMap> <providers> <remove name="MySqlSiteMapProvider"/> </providers> </siteMap>

So I see at least one error:所以我至少看到一个错误:

You have a comma between "collegedata, Uid" and not a semicolon. “collegedata, Uid”之间有一个逗号,而不是分号。

your connection string:你的连接字符串:

String DSN = "Data Source = win2012server.db.net; port = 3306; Database = collegedata, Uid = rahul; Pwd = rahul;";

the correct string:正确的字符串:

String DSN = "Data Source = win2012server.db.net; port = 3306; Database = collegedata; Uid = rahul; Pwd = rahul;";

what I would recommend is to remove the space:我建议删除空间:

String DSN = "Data Source=win2012server.db.net;port=3306;Database=collegedata;Uid=rahul;Pwd=rahul;";

暂无
暂无

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

相关问题 使用方法 &#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”对主机或用户进行身份验证失败 - authentication to host or user using method 'mysql_native_password' failed 使用方法“ mysql_native_password”失败 - using method 'mysql_native_password' failed 使用方法“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 使用方法 mysql_native_password 验证失败 - Authentication failed using method mysql_native_password 我收到此错误消息:用户的访问被拒绝(使用密码是) - I got this error message : Access denied for user (Using password YES) 从流读取失败 - mysql_native_password错误 - Reading from stream failed - mysql_native_password error C# - 意外的身份验证方法 mysql_native_password 异常 - C# - Unexpected authentication method mysql_native_password exception
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM