MySQL: Lost the WITH GRANT OPTION Privilege from Root

MySQL
2018-02-26 22:14 (6 years ago) ytyng

While managing the root user with the mysql_user module in Ansible, I found that I was no longer able to grant privileges to other users.

When I checked the grants for root, I saw:

mysql> show grants;
+--------------------------------------------------------------+
| Grants for root@localhost                                    |
+--------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' |
| GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION |
+--------------------------------------------------------------+

The WITH GRANT OPTION was missing.

In such a case, you can forcefully set the Grant_priv by executing:

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

(You might need to run FLUSH PRIVILEGES; afterward?)

The correct show grants should look like this:

mysql> show grants;
+---------------------------------------------------------------------+
| Grants for root@localhost                                           |
+---------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION |
| GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION        |
+---------------------------------------------------------------------+

This is how it should appear.

Currently unrated

Comments

Archive

2024
2023
2022
2021
2020
2019
2018
2017
2016
2015
2014
2013
2012
2011