How can I restore the MySQL root user’s full privileges

主宰稳场 提交于 2019-12-22 00:24:20

问题


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)?

i m using my sql work bench 6.0

please let me know soultion step by step as i m new in my sql.


回答1:


First try

GRANT ALL ON *.* TO 'root'@'localhost';

if that does not work then do the following

  1. Stop mysqld service with this ( on UNix-like systems)

    sudo mysqld stop

  2. Restart it with the --skip-grant-tables option.

  3. Connect to the mysql with just: mysql (i.e. no -p option, and username may not be required).

  4. Use the following in the mysql client:

    UPDATE mysql.user SET Grant_priv='Y', Super_priv='Y' WHERE User='root';

  5. Flush the privileges by running

    FLUSH PRIVILEGES;

  6. Remove --skip-grant-tables option. and restart mysqld

  7. Finally run

    GRANT ALL ON *.* TO 'root'@'localhost';



来源:https://stackoverflow.com/questions/24027487/how-can-i-restore-the-mysql-root-user-s-full-privileges

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!