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

2019-04-15 16:13发布

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条回答
家丑人穷心不美
2楼-- · 2019-04-15 16:30

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';

查看更多
登录 后发表回答