如何恢复MySQL root用户权限?
我不小心删除了 MySQL root 用户的大部分权限,包括授予权限的能力。有什么方法可以将该用户恢复到原始状态吗?
I accidentally removed most of the privileges from my MySQL root user, including the ability to grant privileges. Is there some way I can restore this user to its original state?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能仍然可以对数据库
mysql
中的表user
执行UPDATE
:如果步骤 3 不起作用,则重新启动 MySQL 服务器将具有相同的效果。如果步骤 2 不起作用,您需要从备份中恢复
mysql.user
。如果您没有备份,请进行备份,重新安装 MySQL,然后有选择地恢复备份,并保留mysql
数据库中的表。更新
您在第一步中被拒绝访问。此时,您需要使用备份的替代解决方案。 (据我所知或可以轻松想象)您不可能以任何其他方式恢复这些表。
更新2
确切的错误消息基本上是说,除了失去root的
grant
权限之外,您还删除了root对mysql
数据库的访问权限。如果无法访问该数据库,也没有授予
权限,我能看到的唯一方法就是以某种方式获取mysql
数据库的新副本。您是否有机会设置复制从站?
You might still be able to do an
UPDATE
on tableuser
in databasemysql
:If step 3 doesn't work, restarting the MySQL server will have the same effect. If step 2 doesn't work, you need to restore
mysql.user
from backup. If you don't have a backup, make a backup, reinstall MySQL and then selectively restore your backup, leaving out tables within themysql
database.UPDATE
You're getting Access Denied during the first step. At this point, you're down to the alternative solutions with backups. There's no way (that I know of or can easily imagine) that you're recovering those tables any other way.
UPDATE 2
The exact error message is basically saying that in addition to losing root's
grant
privileges, you've dropped root's access to themysql
DB. Without having access to that DB and without havinggrant
privileges, the only way I can see back is to somehow obtain a fresh copy of themysql
DB.Any chance you have a replication slave set up?