如何还原MySQL root用户的全部权限 [英] How can I restore the MySQL root user’s full privileges
问题描述
我不小心从MySQL根用户中删除了所有特权
I accidentally removed all the privileges from my MySQL root user,
是否可以通过某种方式将该用户恢复为原始状态(具有所有特权)?
Is there some way I can restore this user to its original state (with all privileges)?
我正在使用我的SQL Work Bench 6.0
i m using my sql work bench 6.0
请让我逐步了解灵魂,因为我是sql的新手.
please let me know soultion step by step as i m new in my sql.
推荐答案
第一次尝试
GRANT ALL ON *.* TO 'root'@'localhost';
如果这不起作用,请执行以下操作
if that does not work then do the following
-
使用此功能(在类似UNix的系统上)停止
mysqld
服务
sudo mysqld stop
使用--skip-grant-tables
选项重新启动.
只需使用以下命令即可连接到mysql:mysql
(即,没有-p选项,并且可能不需要用户名).
Connect to the mysql with just: mysql
(i.e. no -p option, and username may not be required).
在mysql客户端中使用以下内容:
Use the following in the mysql client:
UPDATE mysql.user SET Grant_priv='Y', Super_priv='Y' WHERE User='root';
通过运行刷新特权
FLUSH PRIVILEGES;
删除--skip-grant-tables
选项.并重新启动mysqld
Remove --skip-grant-tables
option. and restart mysqld
最终运行
GRANT ALL ON *.* TO 'root'@'localhost';
这篇关于如何还原MySQL root用户的全部权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!