How can I restore the MySQL root user full privileges?


We can restore the MySQL root user full privileges with the help of UPDATE command.

Firstly, you need to stop mysqld and restart it with the --skip-grant-tables option. After that, connect to the mysqld server with only mysql (i.e. no -p option, and username may not be required).

Issue the below given command in the mysql client to restore the MySQL root user with full privileges.

mysql> UPDATE mysql.user SET Grant_priv = 'Y', Super_priv = 'Y' WHERE User = 'root';
Query OK, 0 rows affected (0.04 sec)
Rows matched: 1  Changed: 0  Warnings: 0

Above, we have set super privilege.

Super_priv = 'Y'

Now we need to flush the privileges with the help of the FLUSH command.

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.18 sec)

Updated on: 30-Jul-2019

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements