简体   繁体   English

由于异常,无法从C#应用程序访问MySQL:“拒绝访问用户'root'@'localhost'(使用密码:YES)”

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

相关问题 用户'root'@'localhost'的访问被拒绝(使用密码:是) - Access denied for user 'root'@'localhost' (using password: YES) 在Visual Studio中拒绝用户'root'@'localhost'的访问(使用密码:是) - Access denied for user 'root'@'localhost' (using password: YES) in Visual Studio 带有实体框架6的mysql 5.7-拒绝用户'root'@'localhost'的访问(使用密码:NO) - mysql 5.7 with entity framework 6 - Access denied for user 'root'@'localhost' (using password: NO) ASP.NET MVC MySQL 访问拒绝用户“root”@“localhost”(使用密码:NO) - ASP.NET MVC MySQL Access denied for user 'root'@'localhost' (using password: NO) 连接器/NET 连接到 MSSQL 错误 - 用户 'sa'@'localhost' 的访问被拒绝(使用密码是) - Connector/NET connecting to MSSQL error - access denied for user 'sa'@'localhost' (using password yes) 用户 ''@localhost 的访问被拒绝(使用密码:否) - Access denied for user ''@localhost (using password: no) 方法'mysql_native_password'失败并显示消息:用户''@'RAHUL-PC'的访问被拒绝(使用密码:是) - method 'mysql_native_password' failed with message: Access denied for user ''@'RAHUL-PC' (using password: YES) MySql.Data.MySqlClient.MySqlException:“用户'hobo'@'49.70.207.34'的访问被拒绝(使用密码:是)” - MySql.Data.MySqlClient.MySqlException:“Access denied for user 'hobo'@'49.70.207.34' (using password: YES)” 我收到此错误消息:用户的访问被拒绝(使用密码是) - I got this error message : Access denied for user (Using password YES) C#远程MySQL-用户的访问被拒绝 - C# Remote MySQL - Access Denied For User
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM