MySQL 如何删除MySQL root密码
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3032054/
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
How to remove MySQL root password
提问by nectar
I want to remove the password for user root in localhost. How can I do that? By mistake I have set the password of root user. That's why phpmyadmin is giving an error:
我想删除本地主机中用户 root 的密码。我怎样才能做到这一点?我错误地设置了root用户的密码。这就是 phpmyadmin 给出错误的原因:
#1045 - Access denied for user 'root'@'localhost' (using password: NO)
#1045 - Access denied for user 'root'@'localhost' (using password: NO)
回答by Dario
You need to set the password for root@localhost
to be blank. There are two ways:
您需要将密码设置为root@localhost
空白。有两种方式:
The MySQL
SET PASSWORD
command:SET PASSWORD FOR root@localhost=PASSWORD('');
Using the command-line
mysqladmin
tool:mysqladmin -u root -pType_in_your_current_password_here password ''
MySQL
SET PASSWORD
命令:SET PASSWORD FOR root@localhost=PASSWORD('');
使用命令行
mysqladmin
工具:mysqladmin -u root -pType_in_your_current_password_here password ''
回答by Faiz Akhtar
I have also been through this problem,
我也遇到过这个问题
First i tried setting my password of root to blank using command :
首先,我尝试使用命令将 root 的密码设置为空白:
SET PASSWORD FOR root@localhost=PASSWORD('');
But don't be happy , PHPMYADMIN uses 127.0.0.1 not localhost , i know you would say both are same but that is not the case , use the command mentioned underneath and you are done.
但是不要高兴,PHPMYADMIN 使用 127.0.0.1 而不是 localhost,我知道您会说两者相同,但事实并非如此,使用下面提到的命令即可完成。
SET PASSWORD FOR [email protected]=PASSWORD('');
Just replace localhost with 127.0.0.1 and you are done .
只需将 localhost 替换为 127.0.0.1 即可。