How to get all privileges back to the root user in

2019-01-20 08:55发布

I am using MySQL. My root user doesn't have all privileges. How can I get all privileges back to the root user? How to do it step by step?

3条回答
戒情不戒烟
2楼-- · 2019-01-20 08:55

This worked for me on Ubuntu:

Stop MySQL server:

/etc/init.d/mysql stop

Start MySQL from the commandline:

/usr/sbin/mysqld

In another terminal enter mysql and issue:

grant all privileges on *.* to 'root'@'%' with grant option;

You may also want to add

grant all privileges on *.* to 'root'@'localhost' with grant option;

and optionally use a password as well.

flush privileges;

and then exit your MySQL prompt and then kill the mysqld server running in the foreground. Restart with

/etc/init.d/mysql start  
查看更多
小情绪 Triste *
3楼-- · 2019-01-20 08:57

Log in as root, then run the following MySQL commands:

GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost';
FLUSH PRIVILEGES;
查看更多
冷血范
4楼-- · 2019-01-20 08:58

If you facing grant permission access denied problem, you can try mysql_upgrade to fix the problem:

/usr/bin/mysql_upgrade -u root -p

Login as root:

mysql -u root -p

Run this commands:

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost';
mysql> FLUSH PRIVILEGES;
查看更多
登录 后发表回答