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

标签 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)

最佳答案

只需在您的连接字符串中添加密码,因为您还没有在您的连接中添加它。

关于c# - 使用方法 'localhost' 对用户 'root' 的主机 'mysql_native_password' 的身份验证失败并显示消息(使用密码 : NO),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39442151/

相关文章:

c# - 在调用基础构造函数之前处理参数

c# - 从 appsettings.json 文件中读取会出现 NullReferance 错误

java - 在hibernate中使用继承将对象从子类表复制到父类(super class)表

php - 尝试使用按钮从我的数据库中删除一行

mysql - Excel VBA ODBC 连接导入的列格式

c# - 访问 SearchDescriptor 属性以进行测试

c# - 什么时候不调用 dispose 方法?

mysql - 为什么此 MySQL 查询在一台服务器上比另一台服务器慢?

c# - 如何将一个项目的源文件包含到另一个项目中?

mysql - GROUP BY 如何过滤掉同一个表的另一行中具有类似写入值的组?