[英]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.