我不小心在MySQL上锁定了root用户 [英] I've accidentally locked out root on MySQL

查看:290
本文介绍了我不小心在MySQL上锁定了root用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在OS X上使用MySQL,并使用DROP USER删除了所有"root"用户.然后,我将其中一些添加回去并执行GRANT ALL on *.* to 'root'@'localhost';,然后在确认确实可以登录并执行一些特权操作后注销.

I was playing around with MySQL on OS X and I removed all the 'root' users using DROP USER. I then added some of them back and did GRANT ALL on *.* to 'root'@'localhost';, and then logged out after verifying that yes indeed, I could log in and do a few privileged operations.

不幸的是,我未尝试执行的特权操作之一是GRANT ALL on *.*.事实证明,您没有使用GRANT ALL命令授予特权的特权.所以现在我被卡住了.我不能给任何人做任何其他事情的特权.

Unfortunately, one of the privileged operations I did not try was GRANT ALL on *.*. It turns out that you don't get the privilege to grant privileges with the GRANT ALL command. So now I'm stuck. I can't give anybody any privileges to do anything else.

在这一点上,我实际上在MySQL中没有任何数据.我可以擦拭安装并重新安装.但是我想解决这个问题而不求助于极端.我该怎么办?

At this point I don't actually have any data in MySQL. I could just wipe the install and do it over. But I would like to fix this without resorting to that extreme. How do I do that?

推荐答案

将以下内容放入文件中:

Put the following in a file:

GRANT ALL ON *.* TO 'root'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;

使用 --init-file 选项重新启动mysqld文件.

这篇关于我不小心在MySQL上锁定了root用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆