MySQL 我的 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/49091983/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
My ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
提问by L. Drail
When I try to connect the MySQL Server by command:
当我尝试通过命令连接 MySQL 服务器时:
mysql -u root -p
I get error "Access denied". I'm sure that the password is right.
我收到错误“拒绝访问”。我确定密码是正确的。
When I use the
当我使用
mysqld --defaults-files "xxx\my.ini" --console --skip-grant-tables
option, I can access in, but when I quit this, access is denied again.
选项,我可以访问,但是当我退出时,访问再次被拒绝。
How could I sovle it?
我怎么能解决它?
回答by Ortomala Lokni
You can reset the root password.
您可以重置root密码。
For MySQL 5.7.6 and later:
对于 MySQL 5.7.6 及更高版本:
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
MySQL 5.7.5 and earlier:
MySQL 5.7.5 及更早版本:
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('MyNewPass');
This can be dangerous, read the full official instructions before: How to Reset the Root Password?
这可能很危险,请先阅读完整的官方说明:如何重置 Root 密码?
回答by Korteby Farouk
Try Resetting the Root Password: Generic Instructions
- Restart mysql with the --skip-grant-tables option
- In the mysql client :
FLUSH PRIVILEGES;
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('MyNewPass');
- 使用 --skip-grant-tables 选项重新启动 mysql
- 在 mysql 客户端中:
FLUSH PRIVILEGES;
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('MyNewPass');