使用方法'mysql_native_password'对用户'root'的主机'localhost'进行身份验证失败,并显示消息(使用密码:NO)

时间:2016-09-12 01:06:35

标签: c# mysql

你能帮我们找我的论文,这是我系统中的一个问题。

MySqlConnection cn2 = new MySqlConnection(cn.ConnectionString);
cn2.Open();-->>> Authentication to host 'localhost' for user 'root' using method 'mysql_native_password' failed with message: Access denied for user 'root'@'localhost' (using password: NO)

listView1.Items.Clear();
string sql = "Select * from tblrecord where DateTime between '" + dateTimePicker1.Value + "' and '" + dateTimePicker2.Value + "'";
cm = new MySqlCommand(sql);
//cm = new MySqlCommand(sql, cn1);
dr = cm.ExecuteReader();
dr.Read();
if (dr.HasRows)

1 个答案:

答案 0 :(得分:1)

只需在连接字符串中添加密码,因为您尚未在连接中添加密码。