[英]Unable to access MySQL from C# application because of Exception: “Access denied for user 'root'@'localhost' (using password: YES)”
I am making a simple application and while connecting it to the MySQL Database I have running using WAMP Server, it is throwing an exception and can't connect. 我正在制作一个简单的应用程序,并将其连接到我使用WAMP服务器运行的MySQL数据库,它抛出异常而无法连接。
An unhandled exception of type 'MySql.Data.MySqlClient.MySqlException' occurred in MySql.Data.dll MySql.Data.dll中发生未处理的“MySql.Data.MySqlClient.MySqlException”类型异常
Additional information: Authentication to host 'localhost' for user 'root' using method 'mysql_native_password' failed with message: Access denied for user 'root'@'localhost' (using password: YES) 附加信息:使用方法'mysql_native_password'对用户'root'的主机'localhost'进行身份验证失败,并显示消息:用户'root'访问被拒绝@'localhost'(使用密码:YES)
I have tried changing the users, database names but still nothing works. 我试过更改用户,数据库名称,但仍然无效。
The string I am using for establishing the connection is 我用来建立连接的字符串是
string MyConnectionString = "Server=localhost;Database=testdb;Uid=root;Pwd=root1234;";
Please Help. 请帮忙。 I have a project due on Monday morning. 我周一早上有一个项目。
I got it now. 我现在明白了。 The problem was I had installed MySQL Community version and also had MySQL in WAMP so very probably they both were causing conflicts. 问题是我已经安装了MySQL社区版本,并且在WAMP中也有MySQL,所以很可能它们都引起了冲突。 I uninstalled both and reinstalled WAMP. 我卸载了两个并重新安装了WAMP。 That worked. 那很有效。
You can create user in MySql 您可以在MySql中创建用户
CREATE USER 'username'@'servername' IDENTIFIED BY 'password';
or using phpmyadmin select database and create a new user or update password 或使用phpmyadmin选择数据库并创建新用户或更新密码
If you are using wamp xamp like packs be carefull becouse if you change root password phpmyadmin would be break; 如果你正在使用wamp xamp like pack,请仔细考虑如果你改变root密码phpmyadmin就会破解;
i suggest create a new user and give root previlliges to that user and NEVER USE root user in production 我建议创建一个新用户并为该用户提供root权限,并且永远不要在生产中使用root用户
good luck. 祝好运。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.